tuple and list 练习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tuple and list 练习相关的知识,希望对你有一定的参考价值。
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 练习的主要内容,如果未能解决你的问题,请参考以下文章