Python列表推导式
int_list = range(1, 55, 2)
print(list(int_list))
结果:
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53]
int_list = range(1, 55, 2)
print([str(x) for x in int_list])
结果:
['1', '3', '5', '7', '9', '11', '13', '15', '17', '19', '21', '23', '25', '27', '29', '31', '33', '35', '37', '39', '41', '43', '45', '47', '49', '51', '53']
int_list = range(1, 55, 2)
print([x * 10 for x in int_list])
结果:
[10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490, 510, 530]
QQ:1061767621
Q群:215481318