当我尝试print在Python中使用语句时,它给了我这个错误:
>>> print "Hello, World!"
File "<stdin>", line 1
print "Hello, World!"
^
SyntaxError: Missing parentheses in call to 'print'
Run Code Online (Sandbox Code Playgroud)
那是什么意思?
为什么在Python 3中打印字符串时会收到语法错误?
>>> print "hello World"
File "<stdin>", line 1
print "hello World"
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud) 我理解语句和表达式之间的区别,我理解Python3将print()转换为函数.
但是我在各种Python2.x解释器上运行了一个用括号括起来的print()语句,它运行完美,我甚至不需要导入任何模块.
我的问题:以下代码print("Hello SO!")是否作为Python2.x中的语句或表达式进行了评估?