1、reload
python2.7:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
python3.6改为:
import importlib
importlib.reload(sys)
2、input
python2.7:
a = raw_input
python3.6改为:
a = input()
详见:菜鸟教程--python3.X和python2.X中input()和raw_input()区别
3、cmp
python2.7:
cmp('hello', 'world')
python3.6改为:
import operator
operator.eq('hello', 'world')
详见:Python3中替代Python2中cmp()函数的新函数(gt,ge,eq,le,lt)
最后
以上就是愤怒发卡最近收集整理的关于python3.6和python2.7区别 小记的全部内容,更多相关python3.6和python2.7区别内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复