最近打算学习下python,下载了最新的版本3.3,可惜从图书馆借到的教材都不是3.3版本的,发现有很多地方不一样
1.数据持久化:
import dbm这是3.3版本的,其他的是import dbhash
查找他的帮助文档,是这么说的:
-
Some related modules have been grouped into packages, and usually the submodule names have been simplified. The resulting new packages are:
- dbm (anydbm, dbhash, dbm, dumbdbm, gdbm, whichdb).
- html (HTMLParser, htmlentitydefs).
- http (httplib, BaseHTTPServer, CGIHTTPServer, SimpleHTTPServer, Cookie, cookielib).
- tkinter (all Tkinter-related modules except turtle). The target audience of turtle doesn’t really care about tkinter. Also note that as of Python 2.6, the functionality of turtle has been greatly enhanced.
- urllib (urllib, urllib2, urlparse, robotparse).
- xmlrpc (xmlrpclib, DocXMLRPCServer, SimpleXMLRPCServer).
for k,v in db.iteritems():
print(k,v)
提示没有iteritems这个方法,最后还是查找文档,发现替换为items()