如何在Python中打印一个简单的字符串[重复]

问题描述 投票:0回答:2

我有centos 6.5
如果我输入 python,我会得到:

Python 3.3.2 (default, Oct 30 2013, 08:01:17) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux

我创建了一个文件 1.py:

print "Goodbye, World!"

我愿意

python ./1.py

我明白了

  File "./1.py", line 1
    print "Goodbye, World!"
                          ^
SyntaxError: invalid syntax
python python-3.x centos centos6.5
2个回答
0
投票
print("Goodbye, World!")

print
是Python 3中的函数


0
投票

print是python 3中的函数,您使用的语法对应于python2。

所以,你需要做

print("Goodbye, World!")
© www.soinside.com 2019 - 2024. All rights reserved.