@
callofmx 换了 cpickle 也一样
我用了 pickle 写文件方式 再读取不会出现 redis 中的问题
#!/usr/bin/env python
import pickle
appinfo = {
'a': {'172.25.53.12': {'olversion': u'111', 'rb1': u'222', 'rb2': u'333'}},
'c': {'172.25.53.14': {'olversion': u'111', 'rb1': u'222', 'rb2': u'333'}},
'b': {'172.25.53.11': {'olversion': u'111', 'rb1': u'222', 'rb2': u'333'}},
'd': {'172.25.53.13': {'olversion': u'111', 'rb1': u'222', 'rb2': u'333'}}}
#op = operate_redis()
#appinfo = op.read_from_redis('5006')
p = pickle.dumps(appinfo)
with open('test.txt', 'wb+') as f:
f.write(p)
f.seek(0)
info = pickle.loads(f.read())
print "==========="
print "==========="
info['a']['172.25.53.12']['rb1'] = 'gofuckyourself' #只修改 a 对应的 b c d 中 rb1 不变
print info