如何用Python命令字典?

时间:2013-05-01 04:16:29

标签: python dictionary

为什么字典与添加键:值对的顺序不同?

def main():
    dictionary = {}
    names = ['a', 'd', 'g', 's', 'b', 'm', 'f', 'p']
    moves = [1,2,3,4,5,6,7,8]
    for k in range(len(names)):
        dictionary[names[k]] = moves[k]
        print player_dictionary
        print "\n"

main()

0 个答案:

没有答案