1. 程式人生 > >python2 與python3的print 差別

python2 與python3的print 差別

sky linux format python2 int orm 成了 edit lin

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