标签: python python-3.x
在字典中是否存在使用all()函数检查某个键的任何方法,仅在一行代码中。例如:
d = {"x": 1, "y":2} if all("x" and "y" in d): # this way didn't work # do-something