classtuple([iterable])# tuple是可迭代的
Tuples may be constructed in a number of ways:# tuple可以通过多种方式来进行构建:
Using a pair of parentheses to denote the empty tuple:()# 使用一对括号表示空元组:()
Using a trailing comma for a singleton tuple: a,or(a,)#使用逗号作为单例元组:a,或(a,) [需要加逗号哦,不然会被认为是别的数据]
Separating items with commas: a, b, c or(a, b, c)# 用逗号分隔项目:a, b, c或(a, b, c)
Using the tuple() built-in:tuple()ortuple(iterable)#使用内置的tuple(): tuple()或tuple(iterable) 进行构建
The constructor builds a tuple whose items are the same andin the same order as iterable’s items.#构造函数构建一个元组,其中的项与iterable的项相同,且顺序相同。
iterable may be either a sequence, a container that supports iteration,or an iterator object.#iterable可以是序列、支持迭代的容器或迭代器对象。
If iterable is already a tuple, it is returned unchanged.#如果iterable已经是一个元组,那么它将不加修改地返回。
For example,tuple('abc') returns ('a','b','c')andtuple([1,2,3]) returns (1,2,3). If no argument is given, the constructor creates a new empty tuple,().# tuple 就是将数据转换元组的内置函数 #print(tuple())#() 没有数据 就返回一个空元组
Note that it is actually the comma which makes a tuple,not the parentheses.#注意,构成元组的实际上是逗号,而不是圆括号。
The parentheses are optional