【python】msgpack使用

1.存储数据

import msgpack
var={'a':'this','b':'is','c':'a test'}
with open('file.name','wb') as f:
    msgpack.dump(var, f)

2.取出数据

import msgpack
with open('file.name','rb') as f:
    var = msgpack.load(var, f)
print var

 

此外:json, pickle都可以用于数据的序列化和存储

 

posted @ 2016-01-05 18:24  匡子语  阅读(2811)  评论(0编辑  收藏  举报