代码
#列表推导式
#C语言编程思维的写法
a_list = []
for i in range(1,11):
if i % 2 == 0:
a_list.append( i*i )
print(a_list)
#Python中的写法
b_list = [i*i for i in range(1,11) if i % 2 == 0]
print(b_list)
#字典推导式
chinese_zodiac = '猴鸡狗猪鼠牛虎兔龙蛇马羊'
#之前的方法
# z_num = {}
# for i in chinese_zodiac:
# z_num [i] = 0
#现在的写法
z_num = {i:0 for i in chinese_zodiac}
print(z_num.keys())