美文网首页
python2与python3的差别

python2与python3的差别

作者: BigBigTang | 来源:发表于2019-03-07 19:04 被阅读0次

1.print

在python2中是语句,python3中是函数
所以在python2中可以这么写

print 'a'

python3中则要这么写:

print('a')

2.range

python2-range(10)返回一个列表
python3-range(10)返回迭代器

3.编码

python2-默认ascii,中文需要在头部写# -*- coding:utf-8 -*-
python3-默认utf-8,中文直接可以显示

4.input

python2-raw_input()
python3-input()

相关文章

网友评论

      本文标题:python2与python3的差别

      本文链接:https://www.haomeiwen.com/subject/iuphpqtx.html