标签:microsoft append 修改 apple pytho python php col bar
1 ‘create a list ‘ 2 classmates = [‘Jo‘,‘Joo‘,‘Jooo‘] 3 4 print(len(classmates)) 5 6 print(classmates[0]) 7 print(classmates[1]) 8 print(classmates[2]) 9 # print(classmates[4]) #越界取值会报错 10 11 print(classmates[-1]) 12 print(classmates[-2]) 13 print(classmates[-3]) 14 15 classmates.append(‘Joooo‘) 16 print(classmates) 17 18 classmates.insert(1,‘Jo1‘) 19 print(classmates) 20 21 classmates.pop() #删除最后一个元素 22 print(classmates) 23 24 classmates.pop(1)#删除序号为1的元浸塑 25 print(classmates) 26 27 classmates[1] = ‘Jo1‘#修改序号为1的元素为Jo1 28 29 print(classmates) 30 31 classmates = (‘Jo1‘,‘Jo2‘,‘Jo3‘,‘Jo4‘) 32 print(type(classmates)) 33 print(classmates) 34 ‘定义一个空tuple‘ 35 tuple_0 = () 36 print(type(tuple_0))#<class ‘tuple‘> 37 38 tuple_1 = (1) 39 print(type(tuple_1))#<class ‘int‘> 40 41 tuple_11 = (1,) 42 print(type(tuple_11))#<class ‘tuple‘> 43 44 45 tuple_conxp = (1,2,[‘A‘,‘B‘]) 46 print(tuple_conxp[2]) 47 tuple_conxp[2][0] = ‘X‘ 48 tuple_conxp[2][1] = ‘Y‘ 49 print(tuple_conxp[2][0]) 50 print(tuple_conxp[2][1]) 51 print(tuple_conxp[2]) 52 53 54 L = [ 55 [‘Apple‘,‘Google‘,‘Microsoft‘], 56 [‘Java‘,‘Python‘,‘Ruby‘,‘PHP‘], 57 [‘Adam‘,‘Bart‘,‘Lisa‘] 58 ] 59 print(L[0][0]) #Apple 60 print(L[1][1]) #Python 61 print(L[2][2]) #Lisa
标签:microsoft append 修改 apple pytho python php col bar
原文地址:https://www.cnblogs.com/jpr-ok/p/9329253.html