how to execute a python script file with an argument from inside another python script file

前端 未结 5 1507
灰色年华
灰色年华 2020-12-01 14:05

my problem is that I want to execute a python file with an argument from inside another python file to get the returned values....

I don\'t know if I\'ve explained

5条回答
  •  醉酒成梦
    2020-12-01 14:57

    I suggest you reorganized your getCameras.py, wrap the get camera list code in a method called get_cameras(). Then you can call this method in other python scripts.

    getCameras.py

    def get_cameras():
    bulabula...
    if __name__ == '__main__':
    return get_cameras()
    

    How to use: other.py

    import getCameras
    camera_list = getCameras.get_cameras()
    

提交回复
热议问题