I have two list of strings, and want to link them together in this way:
我对python比较陌生,目前正忙于一个项目。
更具体一点。我有两个字符串列表,希望它们按以下方式链接:
1 2 3 | list1 = ["P1","P2","P3" ] list2 = ["1","2","3" ] |
但是,我想要这个
1 2 3 | P1 = 1 P2 = 2 |
等。
我如何解决这个问题?
由
1 2 3 4 5 6 7 8 9 10 | d = dict(zip(list1,list2)) print (d) {'P3': '3', 'P2': '2', 'P1': '1'} #select by keys print (d['P1']) 1 print (d['P2']) 2 |