记录python2.7迁移到python3.6过程中的一些代码差异

python2.7 python 3.6
import urllib2 import urllib
import urlparse import urllib
import exceptions 废弃
urllib2.urlopen urllib.request.urlopen
urllib2.Request urllib.request.Request
urllib.urlencode urllib.parse.quote
urllib.urldecode urllib.parse.unquote
dict.has_key(xx) xx in dict
types.StringType type('')
types.UnicodeType 废弃
types.ListType type([])
types.DictType type({})
types.IntType type(1)
types.BooleanType type(True)
types.LongType type(1)
types.FloatType type(1.1)
except Exception,err except Exception as err
print xxx print(xxx)

posted on 2019-10-31 17:16  ahfuzhang  阅读(194)  评论(0编辑  收藏  举报