tuple and list 练习
程序员文章站
2022-04-06 07:54:10
...
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 练习的详细内容,更多请关注其它相关文章!
上一篇: 仅用CSS 创建各种不同的图形形状
推荐阅读