Python 判断值是否在字典的键中
可以使用 'in' 关键字来判断一个值是否存在于字典的键中。以下是一个示例:
my_dict = {'a': 1, 'b': 2, 'c': 3}
if 'a' in my_dict:
print('a is in the dictionary keys')
else:
print('a is not in the dictionary keys')
输出:
a is in the dictionary keys
原文地址: https://www.cveoy.top/t/topic/qhBo 著作权归作者所有。请勿转载和采集!