python2 与python3的print 差别
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python2 与python3的print 差别相关的知识,希望对你有一定的参考价值。
2.x中的print不是个函数,输出格式如下
1 Python 2.7.12+ (default, Aug 4 2016, 20:04:34)
2 [GCC 6.1.1 20160724] on linux2
3 Type "help", "copyright", "credits" or "license" for more information.
4 >>> print "There is only %d %s in the sky."%(1,‘sun‘)
5 There is only 1 sun in the sky.
3.x中的print成了函数,输出格式如下
1 Python 3.5.2+ (default, Aug 5 2016, 08:07:14)
2 [GCC 6.1.1 20160724] on linux
3 Type "help", "copyright", "credits" or "license" for more information.
4 >>> print("There is only %d %s in the sky."%(1,‘sun‘))
5 There is only 1 sun in the sky.
以上是关于python2 与python3的print 差别的主要内容,如果未能解决你的问题,请参考以下文章