繁体   English   中英

Mac上Python的第1行语法错误:python 3.3.2

[英]Syntax Error in Line 1 of Python on Mac: python 3.3.2

我遇到了麻烦,因为我的Python3代码的语法很好。 我刚刚在Mac 10.6.8上下载了python 3.3.2。

这是我在IDLE中的代码,然后是我的TERMINAL错误消息。 当我通过IDLE运行程序时,语法错误消息突出显示python 3.3.2中的第二个“3”。 到底是怎么回事??

闲:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 12:45:22) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> print("Hello")
Hello
>>> 

终端错误消息:

File "hello.py", line 1
Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 12:45:22) 
         ^
SyntaxError: invalid syntax

只放线:

print("Hello")

进入hello.py

我猜您的脚本包含以下行:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 12:45:22) 

它应该只是

print("hello")

甚至更好

#! /usr/bin/env python
print("hello")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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