è¾æ¸å å 表è¨
ããããããããªããï¼
% python3.0 Python 3.0 (r30:67503, Feb 28 2009, 18:36:53) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> a = range(1,11) >>> b = range(11,21) >>> a range(1, 11) >>> b range(11, 21) >>> >>> { k:v for k in a for v in b } {1: 20, 2: 20, 3: 20, 4: 20, 5: 20, 6: 20, 7: 20, 8: 20, 9: 20, 10: 20} >>> c = { k:v for k in a for v in b } >>> c {1: 20, 2: 20, 3: 20, 4: 20, 5: 20, 6: 20, 7: 20, 8: 20, 9: 20, 10: 20} >>> type(c) <class 'dict'> >>>