[英]execute python script from another file (after reaching end of file)
我正在嘗試從另一個文件(例如test.py)執行腳本(例如main.py),我不想調用main的任何功能,而是想從if __name__=="__main__":
開始執行文件if __name__=="__main__":
例:
test.py
def funA():
....
def funB():
....
#the last function of file
def funC():
#here i want to start executing main.py without calling any function.
main.py
def fun_x(arg1):
#do something
if __name__ == "__main__": #execution starts here
arg1=10
x(arg1)
是否可以像這樣直接調用主體?
您可以使用Subprocess模塊“像用戶一樣”調用腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.