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

前端 未结 5 1489
灰色年华
灰色年华 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条回答
  •  Happy的楠姐
    2020-12-01 14:58

    First off, I agree with others that you should edit your code to separate the logic from the command line argument handling.

    But in cases where you're using other libraries and don't want to mess around editing them, it's still useful to know how to do equivalent command line stuff from within Python.
    The solution is os.system(command)
    Atleast on Windows, it brings up a console and executes the command, just the same way as if you had entered it into the command prompt.

    import os
    os.system('getCameras.py "path_to_the_scene" ')
    

提交回复
热议问题