列表,拉锁式儿合并. [ [a,b] for a,b in zip(list1,list2)] #最笨的 a=[1,2,3,4,5] b=[2,3,4,5,6] d=[] for i in range(len(a)): c = [] c.append(a[i]) c.append(b[i]) d.append(c) #列表垂直合并 In [8]: list3 Out[8]: [['11:00', '11:01', '11:02'], ['2', '2', '3']] In [9]: [[a,b]…
1.列表解析 test = [x**2 for x in range(1,11)] 2.切片 test1 = ["a","b","c","d","e"] print(test1[0:3])#第一个到第三个元素 print(test1[:3])#同上 print(test1[-3:])#倒数三个元素 print(test1[:])#复制整个列表 3.元组:不能改变的列表称之为元组 test = (1,2) t…
1 Python根据缩进来进行判断代码行与前一个代码行的关系 for name in names: print(name) names = ['baker','david','philp','rose'] for name in names: print(name.title()+',that was a great trick!') print('I cannot wait to see your next trick '+ name.title()+'\n') print('thank yo…