SyntaxError: Missing parentheses in call to 'print'


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
>>>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM