GitHub 博客园 Nanakon

dbm数据库

import dbm
db = dbm.open('definitions', 'c')
db['mustard'] = 'yellow'
db['ketchup'] = 'red'
db['pesto'] = 'green'

print(len(db)) #3
print(db['pesto']) #b'green'

db.close()

db = dbm.open('definitions', 'r')
print(db['mustard']) #b'yellow'

 

posted on 2016-08-05 09:02  jzm17173  阅读(147)  评论(0)    收藏  举报

导航

轻音