欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Python bsddb
来自开放百科 - 灰狐
(版本间的差异)
(未显示1个用户的1个中间版本) | |||
第45行: | 第45行: | ||
>>> for i in range(100000): db['%d'%i] = '%d'% (i*i) // 100,000 records, 5,040 KB size | >>> for i in range(100000): db['%d'%i] = '%d'% (i*i) // 100,000 records, 5,040 KB size | ||
+ | >>> db['99999'] | ||
+ | '9999800001' | ||
+ | |||
+ | ==Web Example== | ||
+ | |||
+ | [[Category:Python]] |
2010年8月22日 (日) 08:39的最后版本
Hash, BTree and Record Objects
http://docs.huihoo.com/python/2.5/lib/bsddb-objects.html
[编辑] Example
>>> import bsddb >>> db = bsddb.btopen('/tmp/spam.db', 'c') // create db in c:\tmp\spam.db or /tmp/spam.db >>> for i in range(10): db['%d'%i] = '%d'% (i*i) ... >>> db['3'] '9' >>> db.keys() ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] >>> db.first() ('0', '0') >>> db.next() ('1', '1') >>> db.last() ('9', '81') >>> db.set_location('2') ('2', '4') >>> db.previous() ('1', '1') >>> for k, v in db.iteritems(): ... print k, v 0 0 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81 >>> '8' in db True >>> db.sync() 0
>>> db.clear() >>> db.sync() >>> db.keys() [] >>> for i in range(100000): db['%d'%i] = '%d'% (i*i) // 100,000 records, 5,040 KB size >>> db['99999'] '9999800001'
[编辑] Web Example
分享您的观点