列表推导式number_list = [number for number in range(1, 7)]
print(number_list)
------------------
[1, 2, 3, 4, 5, 6]列表推导式加条件语句单ifnumber_list = [number
for number in range(1, 7)
if number % 2 == 0]
print(number_list)
------------------
[2, 4, 6]if elsenumber_list = [number**2
if number % 2 == 0
else number+10
for number in range(1, 7)]
print(number_list)
-----------------------
[11, 4, 13, 16, 15, 36]几个函数split()将字符串进行拆分成一个一个单词无参数a = '
技术
· 2019-01-30
· 335 人浏览
一只胖橘