Tuple sequences

Tuples belonging immutable sequence, can not modify the elements of the tuple. Therefore, no increase in the tuple elements, modifying elements, the elements related to the deletion method. 

 

Create a tuple

1. Create tuples (). Parentheses can be omitted.
 a = (10,20,30) or a = 10,20,30 

2. () Create tuple tuple (iterator object may be) by tuple example:

 b = tuple () # Create an empty tuple objects b = tuple ( "abc")

 b = tuple(range(3)) 

Summary: tuple () may receive a list of strings, other types of sequence, iteration, etc. generated tuples. list () may receive a tuple string, other types of sequences, generating a list iterators. 

 

Guess you like

Origin www.cnblogs.com/elephant-study/p/11572398.html