列表生成式的计算

1.

errorDatas = '100*20*30*70*90*80'
list(i // 10 + i for i in map(int,errorDatas.split('*')))
def num1(i):
    return i // 10 + i

list(map(num1,list(map(int,errorDatas.split('*')))))

2.

list2 = [x * x for x in range(1,10)]
list2

3.

list6 = [str(x)+str(y) for x in range(10) for y in range(10) if x % 2 ==0 and y % 2 == 0]
list6

猜你喜欢

转载自www.cnblogs.com/banzui/p/9232533.html