variable = []
Now variable
refers to an empty list * .
(现在variable
引用空列表* 。)
Of course this is an assignment, not a declaration.
(当然这是一项任务,而非宣言。)
There's no way to say in Python "this variable should never refer to anything other than a list", since Python is dynamically typed. (在Python中没有办法说“这个变量永远不应该引用除列表之外的任何东西”,因为Python是动态类型的。)
* The default built-in Python type is called a list , not an array.
(*默认的内置Python类型称为列表 ,而不是数组。)
It is an ordered container of arbitrary length that can hold a heterogenous collection of objects (their types do not matter and can be freely mixed). (它是一个任意长度的有序容器,可以容纳异质的对象集合(它们的类型无关紧要,可以自由混合)。)
This should not be confused with the array
module , which offers a type closer to the C array
type; (这不应该与array
模块混淆, array
模块提供更接近C array
类型的类型;)
the contents must be homogenous (all of the same type), but the length is still dynamic. (内容必须是同质的(所有相同的类型),但长度仍然是动态的。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…