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

nfeuvbwi  于 4个月前  发布在  Python
关注(0)|答案(2)|浏览(86)

此问题在此处已有答案

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?(11个回答)
9年前关闭。
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

lnlaulya

lnlaulya1#

print("Goodbye, World!")

字符串
print是Python 3中的函数

4bbkushb

4bbkushb2#

print是python 3中的一个函数,你使用的语法对应于python 2。
所以,你需要

print("Goodbye, World!")

字符串

相关问题