目錄python
print({i:i**2 for i in range(10)}) #輸出: {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}
z= zip(['a','b','c','d'],[i for i in range(4)]) dic = {k:v for k,v in z} print(dic) #輸出: {'a': 0, 'b': 1, 'c': 2, 'd': 3}