List 也就是数组,但是这个数组是动态的,用中括号与逗号创建。
Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.
1) Like strings (and all other built-in sequence type), lists can be indexed and sliced.
2) All slice operations return a new list containing the requested elements.
3) Lists also support operations like concatenation.用 + 进行连接
4) Unlike strings, which are immutable, lists are a mutable type.
5) You can also add new items at the end of the list, by using the append()
method.
6) Assignment to slices is also possible, and this can even change the size of the list or clear it entirely.
7) The built-in function len()
also applies to lists.
8) It is possible to nest lists (create lists containing other lists).
以下是今天做的一些小练习