且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用另一个python脚本文件中的参数执行python脚本文件

更新时间:2023-01-23 09:10:59

***的答案是不要.将您的 getCameras.py 编写为

The best answer is don't. Write your getCameras.py as

import stuff1
import stuff2 
import sys

def main(arg1, arg2):
    # do whatever and return 0 for success and an 
    # integer x, 1 <= x <= 256 for failure

if __name__=='__main__':
    sys.exit(main(sys.argv[1], sys.argv[2]))

从你的其他脚本,你可以做

From your other script, you can then do

import getCamera

getCamera.main(arg1, arg2)

或调用 getCamera.py 中的任何其他函数

or call any other functions in getCamera.py