ITPub博客

首页 > IT职业 > IT生活 > python2 与python3的print 差别

python2 与python3的print 差别

IT生活 作者:LeeC 时间:2021-09-09 09:22:11 0 删除 编辑

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.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4352/viewspace-2802732/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-12

  • 博文量
    86
  • 访问量
    659