码迷,mamicode.com
首页 > 编程语言 > 详细

Python学习之路-字典外传

时间:2018-02-21 21:07:27      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:post   nbsp   blog   list   info   class   字典   python   each   

__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学习之路-字典外传

标签:post   nbsp   blog   list   info   class   字典   python   each   

原文地址:https://www.cnblogs.com/JankinYu/p/8457382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!