Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 python 2.6.5 中,dbm 的实例没有 __nonzero__ 或 __len__ 方法,那么为什么它会将 false 评估为布尔值?
>>> a = dbm.open('foo', 'c') >>> if a: 打印 'true' ... >>>
根据python文档,被认为是错误的值类型之一是
任何空映射,例如{}.
{}
由于一个dbm对象是一个映射并且一个新实例是空的,因此它是假的。
dbm