作者grubby (GB)
看板Python
标题[问题] 执行「.py档案」的问题
时间Fri Sep 30 12:57:30 2016
最近在学Pyhton上,遇到执行.py档的问题,在爬文後已经能在
cmd上和在IDLE上用'F5'执行成功,但还是无法在互动式直译器和
IDLE上用指令「python file_name.py」执行成功。
档案位置路径"D:\Python"也加入sys.path中,但还是无法执
行成功,我试过二种不同的输入方式,一个没带路径,一个有带路径
,各别出现以下的错误讯息:
1)没带路径
>>> python test1.py
File "<stdin>", line 1
python test1.py
^
SyntaxError: invalid syntax
2)有带路径
>>> python D:\Python\test1.py
File "<stdin>", line 1
python D:\Python\test1.py
^
SyntaxError: invalid syntax
请问要如何解决?谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.167.87.229
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1475211452.A.D49.html
1F:推 AndyLee76: python *.py是在终端机或命令提示字元用的 09/30 13:38
2F:→ AndyLee76: 不是在python里面打的 09/30 13:38
3F:→ grubby: 原来如此,了解!感谢! 09/30 13:52
4F:推 Typebrook: 顺带一提,想在python档案内使用cmd,可用os.system() 09/30 16:14