2005年07月04日 星期一 00:55
If it's a executable file, a ".exe" file, you can launch it in this way, "xxx.exe < input.txt". The text file "input.txt" will be considered as the standard input. But when I use this trick on python, it doesn't work. The only way to do so is like this "python xxx.py < input.txt". But this method has a problem, that you have to include the full path of "xxx.py" unless it's in your current folder even if "xxx.py" is in a folder which has been include in the eviorment variable "path" on windows. Thus, you can execute you "py" program anywhere by using the command "xxx.py", but when you want to use an exsiting file as it's input, you have to use something like "pythong xxx.py < input.txt". It's very inconvenient as I tried to make my python programs cowork with vim. Sorry for my poor english!
2005年07月04日 星期一 02:03
please put #!/usr/bin/env python in the first line and if you want to take input.txt as the argument, you can refer it at the program as sys.argv[1] ----- Original Message ----- From: "Peter Cai" <newptcai at gmail.com> To: <python-chinese at lists.python.cn> Sent: Monday, July 04, 2005 12:55 AM Subject: [python-chinese] How execute a .py in this way? If it's a executable file, a ".exe" file, you can launch it in this way, "xxx.exe < input.txt". The text file "input.txt" will be considered as the standard input. But when I use this trick on python, it doesn't work. The only way to do so is like this "python xxx.py < input.txt". But this method has a problem, that you have to include the full path of "xxx.py" unless it's in your current folder even if "xxx.py" is in a folder which has been include in the eviorment variable "path" on windows. Thus, you can execute you "py" program anywhere by using the command "xxx.py", but when you want to use an exsiting file as it's input, you have to use something like "pythong xxx.py < input.txt". It's very inconvenient as I tried to make my python programs cowork with vim. Sorry for my poor english! _______________________________________________ python-chinese list python-chinese at lists.python.cn http://python.cn/mailman/listinfo/python-chinese
Zeuux © 2025
京ICP备05028076号