在python
中使用cmd命令的语法是什么?这是我用过的命令。我希望文件被执行。
self.hosts[1].cmd("python h1.py")
答案 0 :(得分:1)
如果您只想执行一个文件,请使用Python 3+ Shell:
exec(open("./filename.py").read())
对于命令行,请使用:
chdir "C:\Users\Documents\Project\"
python filename.py
来源:https://stackoverflow.com/questions/13220620/running-python-files-from-command-line