I have dictionary like this;
csvDict[key] = {'delivery': delivery, 'tanksystemid': tanksystemid}
Im trying to do a condition check like;
tanksystemid=100
for dic in csvDict.values():
if tanksystemid == dic['tanksystemid']:
key of csvDict?
How can i get the key of the csvDict?
You need to just use csvDict.items()
instead of csvDict.values()
. Like (python3) :
tanksystemid=100
for key, dic in csvDict.items():
if tanksystemid == dic['tanksystemid']:
# key of csvDict?
print(f'key: {key}')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.