1for k,vin DictName.items(): 2#遍历字典的键值对,k对应键,v对应值3#k,v 的名字可以自己取,DictName是字典名
举例:
tv_dict = {'芒果台':'湖南卫视', '荔枝台':'江苏卫视', '番茄台':'东方卫视'}
for logo,name in tv_dict.items():
print(logo + '是' + name)
结果:
芒果台是湖南卫视
荔枝台是江苏卫视
番茄台是东方卫视
tv_dict = {'芒果台':'湖南卫视', '荔枝台':'江苏卫视', '番茄台':'东方卫视'}
for logo,name in tv_dict.items():
print(logo + '是' + name)
posted on Through-Target
Powered by:
Copyright © 2021 Through-Target
Powered by .NET 5.0 on Kubernetes