How to run a Python file not in directory from another Python file?

前端 未结 3 921
予麋鹿
予麋鹿 2020-12-11 05:09

Let\'s say I have a file foo.py, and within the file I want to execute a file bar.py. But, bar.py isn\'t in the same directory as foo.py, it\'s in a subdirectory call baz. W

3条回答
  •  遥遥无期
    2020-12-11 05:32

    import sys, change "sys.path" by appending the path during run time,then import the module that will help

提交回复
热议问题