python code
即使存在密钥,我也会收到一个关键错误。
print (dict_month[0:4])
[{' 1月':' Sun'},{' 1月':' Sun'},{' 1月& #39;:' Sun'},{' 1月':' Sun'}}
'January' in dict_month
假
'january' in dict_month
假
答案 0 :(得分:0)
简单的一个班轮:
ServiceHost
#driver values:
>>> any(['January' in ele for ele in l])
你的方法的问题是A.Joly提到的,你有一个IN : l = [{'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}]
OUT : True
。您的方法对于list of dictionary
来说是正确的。