欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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 练习的详细内容,更多请关注其它相关文章!

相关标签: tuple list 练习