本文整理匯總了Python中bsddb.hashopen方法的典型用法代碼示例。如果您正苦於以下問題:Python bsddb.hashopen方法的具體用法?Python bsddb.hashopen怎麽用?Python bsddb.hashopen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bsddb
的用法示例。
在下文中一共展示了bsddb.hashopen方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open
# 需要導入模塊: import bsddb [as 別名]
# 或者: from bsddb import hashopen [as 別名]
def open(file, flag = 'r', mode=0666):
return bsddb.hashopen(file, flag, mode)
示例2: __init__
# 需要導入模塊: import bsddb [as 別名]
# 或者: from bsddb import hashopen [as 別名]
def __init__(self):
Synchronization.__init__(self)
carddb_dir = environ['ALLUSERSPROFILE']
carddb_file = 'cardnames.bdb'
carddb_file = join(carddb_dir, carddb_file)
self.db = hashopen(carddb_file, 'w')
示例3: __init__
# 需要導入模塊: import bsddb [as 別名]
# 或者: from bsddb import hashopen [as 別名]
def __init__(self):
self.db = bsddb.hashopen(DEVFILE)
示例4: db_dump
# 需要導入模塊: import bsddb [as 別名]
# 或者: from bsddb import hashopen [as 別名]
def db_dump(filename, outfile = sys.stdout):
try:
f = bsddb.hashopen(filename, 'r')
db_type = "hash"
except:
f = bsddb.btopen(filename, 'r')
db_type = "btree"
outfile.write("VERSION=3\n") # magic
outfile.write("format=bytevalue\n")
outfile.write("type=%s\n" % (db_type))
outfile.write("HEADER=END\n")
for (key,value) in f.iteritems():
outfile.write(" ")
for c in key:
outfile.write("%02x" % ord(c))
outfile.write("\n")
outfile.write(" ")
for c in value:
outfile.write("%02x" % ord(c))
outfile.write("\n")
outfile.write("DATA=END\n")
#-----------------------------------------------------------------------------
# vim:ft=python