[Python]python's tuple tuple

Source: Internet
Author: User

Tuple properties
python的tuple与列表类似,不同之处在于tuple的元素不能修改。  tuple使用小括号,列表使用方括号。  tuple创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。  tuple与字符串类似,下标索引从0开始,可以进行截取、组合。  tuple中只包含一个元素的时候,也需要在元素后面添加符号,否则()会被作为运算符处理;  
Tuple support operators
python Expressions Description
Len (tuple) Count the number of elements
+ Connection
* Copy
Inch Whether the element exists
For x in Tuple:print x Iteration
Tupel element interception
python Expressions Description
L[n] Read Nth Element
L[-N] Reverse reading the nth element of the countdown
L[n:] Intercept nth element after
Tuple built-in functions
Serial Number Method and Description
1 CMP (TUPLE1,TUPLE2)
2 Len (tuple)
3 Max (tuple) returns the maximum value of an element
4 MIN (tuple) returns the element minimum value
5 Tuple (SEQ) converts a list to a tuple

[Python]python's tuple tuple

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.