做这个:
if key == "name" and item:
意思和这个一样:
if key == "name" and if key == "item":
如果是这样,我完全困惑了深入 Python 中的示例 5.14 http://diveintopython.net/object_oriented_framework/special_class_methods.html。 key 如何同时等于“name”和 item?另一方面,“and item”只是询问 item 是否作为变量存在?
if key == "name" and item:
means if (key == "name") and (item evaluates to True)
.
请记住(item evaluates to True)
可以通过多种方式实现。例如if (key == "name") and []
将评估为False
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)