2024-06-24 13:51:16 发布
网友
字典里有没有快捷的方法来检查关键字?
我可以使用它来代替使用多个in和and运算符,而不是使用以下运算符:
in
and
('somekey' in d) and ('someotherkey' in d) and ('somekeyggg' in d)
set(['somekey', 'someotherkey', 'somekeyggg']).issubset(d)
all( word in d for word in [ 'somekey', 'someotherkey', 'somekeyggg' ] )
相关问题 更多 >
编程相关推荐