🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 特性 ## 迭代 >>> from collections import Iterable >>> isinstance('abc', Iterable) # str是否可迭代 for i, value in enumerate(['A', 'B', 'C']): # list实现下标 for x, y in [(1, 1), (2, 4), (3, 9)]: ## 列表生成式 [x * x for x in range(1, 11)] [x * x for x in range(1, 11) if x % 2 == 0] [m + n for m in 'ABC' for n in 'XYZ'] for k, v in dict.items(): ## 生成器 g = (x * x for x in range(10)) next(g) # 0 next(g) # 1 ... next(g) # 没有的时候回报错 Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration for n in g: