我有这样的字典;
csvDict[key] = {'delivery': delivery, 'tanksystemid': tanksystemid}
我正在尝试进行条件检查;
tanksystemid=100
for dic in csvDict.values():
if tanksystemid == dic['tanksystemid']:
key of csvDict?
如何获取csvDict的密钥?
答案 0 :(得分:0)
您只需要使用csvDict.items()
而不是csvDict.values()
。像(python3)一样:
tanksystemid=100
for key, dic in csvDict.items():
if tanksystemid == dic['tanksystemid']:
# key of csvDict?
print(f'key: {key}')