在Python 3中,print
函数是一个函数而不是一个语句,因此需要使用括号来调用它。如果在调用print
函数时没有使用括号,就会出现SyntaxError: Missing parentheses in call to 'print'
错误。
以下是一个示例代码和解决方法:
# 示例代码
print "Hello, World!"
解决方法是在print
函数的调用中添加括号,使其成为一个函数调用:
# 解决方法
print("Hello, World!")
请注意,这个错误只会在Python 3中出现,因为在Python 2中,print
是一个语句而不是一个函数,不需要使用括号。