Lists, tuples, and strings are sequences.
The sequence can be indexed to get the corresponding value, or a slice of a sequence can be obtained by slicing.
Basic operation of the sequence:
1, Len ()
2, +
3. *
4. Max ()
5, Min ()
6. CMP (STR1,STR2)
7, in
The sample code is as follows:
1str1='ABCDEFG'2 Len (str1)374Str2='12345'5str1+str26//'abcdefg12345'7Str1*38//'ABCDEFGABCDEFGABCDEFG'9 Max (STR1)Ten//g One min (str2) A1 - CMP (STR1,STR2) -1 the 'a' inchstr1 -True
Tuples and lists are very similar, except that tuples are immutable as strings. That is, it is not possible to change its value.
Tuples are defined by (), such as t= (' Tom ', ', ', ' Male '), and the value of the tuple can be passed subscript, such as t[1], then output 30.
Create an empty tuple
Empty_tuple= ()
Create a single tuple
Single_tuple= (2,) must remember to have, number, otherwise is not a single tuple.
Generic tuple
simple_tuple= (' Tom ', ' Male ')
tuple= (' Jack ', ' Luck ', simple_tuple)
Type (simple_tuple) output <type ' tuple ' >
You can assign values like this:
Name,age,sex=simple_tuple
Name//' Tom '
In addition the tuple is not modifiable, if the execution of simple_tuple[1]=31 will be error "TypeError: ' Tuple ' object does not the support item assignment"
http://www.icoolxue.com/play/1922 7th Class List
Python Learning (ix) Python data type: sequence (important)