集合列表字典都可使用
list1=[]
list1=[i for i in range(1,10)]
print(list1)
##带if
list2=[i for i in range(1,10) if i%2==0]
print(list2)
#嵌套
#创建列表[(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
list3=[(i,j) for i in range(1,3) for j in range(0,3)]
print(list3)
2023-10-11 12:40:34
集合列表字典都可使用
list1=[]
list1=[i for i in range(1,10)]
print(list1)
##带if
list2=[i for i in range(1,10) if i%2==0]
print(list2)
#嵌套
#创建列表[(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
list3=[(i,j) for i in range(1,3) for j in range(0,3)]
print(list3)