这个Python if语句评估的是什么?

时间:2018-01-29 08:59:37

标签: python

我是Python的新手,必须将程序转换为Java。我坚持这句话:

if not all(cId in historyCId[rOBE] for cId in cIds):

if()评估中的陈述是什么? (需要用文字解释。)

historyCIdHashMap; cIdsJSONArray

2 个答案:

答案 0 :(得分:4)

docs确切显示了all()的作用:

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

换句话说,您可以将您的陈述重写为:

result = True
for cId in cIds:
    if not cId in historyCId[rOBE]:
        result = False
        break
if not result:
    # do something

答案 1 :(得分:0)

for each json cId in jsonArray cIds:
 if ((even one)cId is not in arraylist of key historyCId[rOBE])
   return true
 else
  return false
相关问题