Tuple: (with ())
And list are different:
1, the list is more flexible, you can add the deletion of arbitrary elements, tuples once created can not be changed;
>>> dir (test)
[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __getattribute__ ' ', ' __getitem__ ', ' __getnewargs__ ', ' __getslice__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __rmul__ ', ' __setattr__ ', ' __ Sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' count ', ' index ']
>>> test[1:]
(2, 3, 4)
>>> Test[:3]
(1, 2, 3)
>>> test[1:]
(2, 3, 4)
>>> Test[:3]
(1, 2, 3)
P.S.
1. The types of elements in lists and elements are not qualified, can be nested, somewhat similar to jagged arrays
2. Slicing
Format Operation string:
1, similar to the C language in the printf class function requirements of the formatted input.
2, the escape of the format control character.
Sequence:
1, List (), New empty list
List (iterable), new list initialized from iterable ' s items
2. ZIP ()---the zip function accepts any number of sequences (including 0 and 1) as parameters, returning a tuple list.
Function:
Define DEF return_value function_name (parameters):
#函数实现
1, function nesting---python support function inline-function internal definition function;
2, Function closure---sub-function can use local variables in the parent function, this behavior is called closure!
Example plots
3. Expand Reading
Python learning diary [2]