训练报错:SyntaxError: invalid syntax

在这里插入图片描述
python2与python3打印print语法的不同所导致的

python2.x中的print不是个函数,输出格式如下

Python 2.7.12+ (default, Aug  4 2016, 20:04:34) 
[GCC 6.1.1 20160724] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "There is only %d %s in the sky."%(1,'sun')
There is only 1 sun in the sky.

print" "

python3.x中的print成了函数,输出格式如下

Python 3.5.2+ (default, Aug  5 2016, 08:07:14) 
[GCC 6.1.1 20160724] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("There is only %d %s in the sky."%(1,'sun'))
There is only 1 sun in the sky.

print( )

猜你喜欢

转载自blog.csdn.net/weixin_42535423/article/details/109479019
今日推荐