Detailed Python tuple tuple

A tuple is  Python  important structure of another sequence, and a list of similar, but also by a series of sorting elements in a particular order. And a list of difference is that the list can be arbitrarily operating element, a variable sequence; and tuples are immutable sequence, i.e. tuple element can be individually modified.

Tuples can be seen as a list of immutable. Typically, the tuple is used to save the contents can not be modified.

 Formally, all the elements of the tuple are placed in a pair of parentheses "()", a comma between adjacent elements "," separated, as shown below:

(Element1, element2, ..., elementN)

From the memory contents, a tuple can be any type of storage integer, real, string, list, data such tuples, and a tuple of the same, may be different types of elements, in this tuple, a variety of types of data, including plastic, strings, lists, tuples. E.g:

("test.com.cn",1,[2,'a'],("abc",3.0))

 

 Require additional note is that, when a tuple created is only one element behind this tuple must be a comma ",", otherwise the Python interpreter will mistake it string.

 

Guess you like

Origin www.cnblogs.com/zy09/p/11590227.html