tuple and list 練習
阿新 • • 發佈:2017-07-06
blog list pan pre 報錯 col logs 逗號 tro
Tuple:
1. __add__
1 a = (1,2,3,4,5,6,7,8,9,) 2 b = (10,11,22,33,44,55,66,), 3 c = (110,112,113,114,), 4 result = a.__add__(b) 5 print(result) #(1, 2, 3, 4, 5, 6, 7, 8, 9, (10, 11, 22, 33, 44, 55, 66)) add(b)裏面只能加一個參數,否則會報錯 6 print(a+b+c) #(1, 2, 3, 4, 5, 6, 7, 8, 9, (10, 11, 22, 33, 44, 55, 66), (110, 112, 113, 114))
1 a = (1,2,3,4,5,6,7,8,9,) 2 b = (10,11,22,33,44,55,66,) 3 c = (110,112,113,114,) 4 result = a.__add__(b) 5 print(result) #(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66) 有沒有逗號的區別哈哈 6 print(a+b+c) #(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66, 110, 112, 113, 114)
tuple and list 練習