可能看起来是一个非常微不足道的问题,但我很好奇,并给出了:
foo = {1: 'one', 2: 'two'}有理由选择以下两种方法中的任何一种吗?
if not 3 in foo:
print 'bar'
if 3 not in foo:
print 'bar'发布于 2013-10-29 19:06:29
它们在功能上是等效的,尽管后者更具pythonic风格。
https://stackoverflow.com/questions/19656469
复制相似问题