标签:app 取出 list new 生成式 lin lis pre print
将list1中的值,依次取出,添加到new_list中
list1 = [1,2,3,4]
new_list = []
for line in list1:
new_list.append(line)
print(new_list)
new_list = []
for line in range(1,10):
new_list.append(line)
print(new_list)
列表生成式
举例
name_list = [‘jason‘, ‘饼哥(大脸)‘, ‘sean‘, ‘egon‘]
new_name_list = [name + ‘_dsb‘ for name in name_list]
print(new_name_list)
标签:app 取出 list new 生成式 lin lis pre print
原文地址:https://www.cnblogs.com/medigrat/p/11859355.html