C:\Users\konglb>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'hello, python world';
File "<stdin>", line 1
print 'hello, python world';
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello,
python world';)?
其实这个错误信息,是因为Python3中取消了以前Python 2中的语法,两者在打印输出的语法上有所差别,所以在Python 3下面使用之前的语法格式就会报错,错误信息已经提示你需要加上括号,字符串可以用单引号或双引号括起来,正确语法格式如下所示:
C:\Users\konglb>python -V
Python 3.6.3
>>> print ('hello,python world')
hello,python world
>>> print("you are right")
you are right
>>>
时间: 2024-11-07 23:00:57