Python 2.7.10 print 函数报错:end of statement expected 解决方法
在 Python 2.7.10 中,print 函数不是一个函数,而是一个语句。在 Python 2 中,你可以使用以下语法来使用 print 语句:
print "Hello, World!"
请注意,print 语句后面不需要添加括号。
如果你希望在 Python 2 中使用类似 Python 3 中的 print 函数,你可以在代码的开头添加以下导入语句:
from __future__ import print_function
然后,你可以使用类似 Python 3 的语法来使用 print 函数:
print("Hello, World!")
这样就可以避免"end of statement expected"错误。
原文地址: https://www.cveoy.top/t/topic/pDgM 著作权归作者所有。请勿转载和采集!