新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

cpy-leveldb功能怎么才能在Python中得到实现-创新互联

这期内容当中小编将会给大家带来有关cpy-leveldb功能怎么才能在Python 中得到实现,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

专注于为中小企业提供成都网站设计、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业子洲免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

cpy-leveldb是在leveldb(google开源的高性能key-value数据库)的CAPI基础上开发的python绑定,目前支持leveldb的Put,Get,Delete,Write操作,以及WriteBatch的原子更新操作。下面小编来讲解下cpy-leveldb功能怎么才能在Python中得到实现?

cpy-leveldb功能怎么才能在Python中得到实现

>>>importleveldb

>>>db=leveldb.LevelDB("/tmp/leveldb")

>>>db.Put("1","111")

>>>db.Put("2","222")

>>>db.Put("3","333")

>>>db.Get("1")

'111'

>>>db.Get("3")

'333'

>>>db.Get("2")

'222'

>>>batch=leveldb.WriteBatch()

>>>foriinxrange(20):

...batch.Put(str(i),"helloworld%i"%i)

...

cpy-leveldb功能怎么才能在Python中得到实现

>>>db.Get("2")

'222'

>>>db.Get("5")

''

>>>db.Write(batch)

>>>db.Get("5")

'helloworld5'

>>>db.Get("2")

'helloworld2'

>>>iter=leveldb.Iterator(db)

Iterator_initexecuted.

>>>iter.First()

>>>iter.Key()

'0'

>>>iter.Value()

'helloworld0'

>>>iter.Last()

>>>iter.Key()

'9'

>>>iter.Value()

'helloworld9'

>>>iter.First()

>>>iter.Next()

>>>iter.Key()

'1'

>>>iter.Next()

>>>iter.Key()

'10'

>>>iter.Next()

>>>iter.Key()

'11'

>>>iter.Value()

'helloworld11'

上述就是小编为大家分享的cpy-leveldb功能怎么才能在Python 中得到实现了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。


网页标题:cpy-leveldb功能怎么才能在Python中得到实现-创新互联
文章分享:http://www.wjwzjz.com/article/dijpjs.html
在线咨询
服务热线
服务热线:028-86922220
TOP