[英]How do I run a python script from a file? (UNIX)
Basically what I want to do is make a file called doPython and in this file I want to do the command: 基本上我想做的是创建一个名为doPython的文件,在这个文件中我想要执行命令:
python myFile.py data.txt
I've tried Googling and making a few scripts but I can't seem to get it to work. 我已经尝试过谷歌搜索和制作一些脚本,但我似乎无法让它工作。 It says "No such file or directory when I try with 它说“我尝试时没有这样的文件或目录
#!/usr/bin/env python
python myFile.py data.txt
#!/usr/bin/env python
says that your script is to be run with the Python interpreter. #!/usr/bin/env python
说你的脚本是用Python解释器运行的。 You just need to call sh
or bash
: 你只需要打电话给sh
或bash
:
#!/bin/sh
python myFile.py data.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.