简体   繁体   中英

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:

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. You just need to call sh or bash :

#!/bin/sh
python myFile.py data.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM