使用zip函數, 把key和value的list組合在一起, 再轉成字典(dict).
keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print dictionary
"""
輸出:
{'a': 1, 'c': 3, 'b': 2}
"""
使用zip函數, 把key和value的list組合在一起, 再轉成字典(dict).
keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print dictionary
"""
輸出:
{'a': 1, 'c': 3, 'b': 2}
"""
1.while循環的格式 while 條件: 條件滿足時,做的事情1 條件滿足時,做的事情2 條件滿足時,做的事情3 ...(省略)... demo