1. print "str" 这种没有括号的语法,在3.x下不支持,3.x只支持print ("str")。另外,print希望不换行在最后加一个“,”,在3.x中不适用了,3.x中可以这样去除换行print("str",end='')
2. import urllib2发现有错 ImportError: No module named urllib2
官网:The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.
Python 3.x中用urllib2被整合到了urllib中,用urllib.request替代。
3. re.findall()3.x的参数更改只能string,bytes类型不再被支持。我们可以bytes.decode('GBK')或bytes.decode('UTF-8'),将bytes转换为string。
4. 目前3.x不支持pyExcelerator。
5. has_key 用in操作取代。
本文介绍了 Python 3.x 版本中与语法及库相关的重大变动,包括 print 语句、urllib 库、re.findall() 方法以及 pyExcelerator 库的变化,并提供了相应的解决方案和注意事项。
2182

被折叠的 条评论
为什么被折叠?



