Reprint: http://www.cnblogs.com/known/archive/2010/09/03/1817499.html
Python has three built-in data structures, lists, tuples, and dictionaries
1. Lists (list)
The list is denoted by a bunch of square brackets "", and you don't want the data to be separated by commas, and once you've created a list, you can add, delete, or search for it.
So the list can be changed.
2. Tuples
Tuples and lists are similar, but tuples cannot be changed! Tuples are represented by (), and each data is separated by commas.
Tuples are often used to make statements or user-defined functions safe to take a set of worthwhile moments,
3. Dictionary (dict)
Key combination, the key must be unique, use immutable objects (such as strings), and the values can be mutable, immutable objects.
The dictionary is denoted by {}, separated by commas between each key-value pair, separated by a colon between the values.
4. Sequence-"list, tuple, string
The two main features of a sequence are indexes and slices (eg.substring)
The index allows us to fetch a specific item from the sequence.
Slicing allows us to get a slice of the sequence, which is part of the sequence
Shoplist[-1]: Represents the last element of a sequence
Shoplist[-2]: The second-to-last element of a sequence
Negative, the position is calculated from the end of the sequence.
The start position is contained in the sequence slice, and the end position is excluded from the slice
The colon is a must
5. Objects and references
shoplist =[‘apple‘, ‘mango‘, ‘carrot‘, ‘banana‘]mylist =shoplist # mylist is just another name pointing to the same object!
Del Shoplist[0] # This deletion would delete both shoplist and mylist
Make a copy of Shoplist
MyList = shoplist[:]
Del Mylist[0] # This del would not affect original shoplist
6. String functions
Python 5 data structure