我一直在使用python的shelve库(不是在多处理环境中),并且在使用has_key()方法时观察到不稳定的行为。当我知道密钥存在于书架中时,它有时返回True,有时返回False。造成这种行为的通常原因是什么?在
import shelve
some_key = 'not relevant'
s = shelve.open('cache.db')
if s.has_key(some_key):
var = s[some_key]
print 'found key', some_key
s.close()
注意:Python2.7,Ubuntu14.04在虚拟机虚拟机中,运行在i7x86-64位
目前没有回答
相关问题 更多 >
编程相关推荐