Python学习之路-字典外传

Posted Python学习之路

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python学习之路-字典外传相关的知识,希望对你有一定的参考价值。

__author__ = "KuanKuan"
info = {teacher1: 苍井空,
      teacher2: 京香,
      teacher3: 波多野结衣,
      teacher4: 小泽玛利亚,
      teacher5: 上原瑞惠,
      teacher6: 樱井莉亚,
      teacher7: 桃谷绘里香}
print(info.keys())
d = list(info.keys())[0]
b = list(info.values())[0]
print(d,b)

for index in range(len(info)):
    print(index,list(info.keys())[index],list(info.values())[index])
print("~"*168)
for index in range(len(info)):
    print(index,list(info.keys()),list(info.values()))
# dict_keys([‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘])
# teacher1 苍井空
# 0 teacher1 苍井空
# 1 teacher2 京香
# 2 teacher3 波多野结衣
# 3 teacher4 小泽玛利亚
# 4 teacher5 上原瑞惠
# 5 teacher6 樱井莉亚
# 6 teacher7 桃谷绘里香
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 0 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 1 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 2 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 3 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 4 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 5 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]
# 6 [‘teacher1‘, ‘teacher2‘, ‘teacher3‘, ‘teacher4‘, ‘teacher5‘, ‘teacher6‘, ‘teacher7‘] [‘苍井空‘, ‘京香‘, ‘波多野结衣‘, ‘小泽玛利亚‘, ‘上原瑞惠‘, ‘樱井莉亚‘, ‘桃谷绘里香‘]

 

以上是关于Python学习之路-字典外传的主要内容,如果未能解决你的问题,请参考以下文章

Python学习之路-字典dict常用方法

python学习之路04——列表和字典

Python自动化3.0-------学习之路-------字典!

python学习之路(基础篇)——列表,字典,集合

python学习之路3

Python学习之路3 - 字符串操作&字典