# 列表推导式 eggs = [] for i in range(10): eggs.append('鸡蛋'+str(i)) print(eggs)
简化
eggs = ['鸡蛋%d'%i for i in range(10)] print(eggs)
【i for i in range(10)】
ret = [i for i in range(30) if i%3==0] print(ret)
a.count(X) # a中的X出现的次数