You aren't limited to passing a sequence directly into the constructor; you can also pass a variable that holds a tuple or a string into the list constructor.
您不仅能够将序列直接传递给构造函数,还可以将拥有元组或字符串的变量传递给list 构造函数。
You can create a tuple by simply assigning a sequence of objects, separated by commas, to a variable (see Listing 5).
您只需向变量分配一个用逗号分隔的对象序列,就可以创建一个tuple(参见清单5)。
Once the code has iterated over all the elements in the tuple, it enters the else clause of the for loop, which prints out the value of the count variable.
一旦代码已经迭代了tuple中的所有元素,它将进入for循环的else子句,打印count变量的值。
The following example shows how to loop over a sequence, and how to use a tuple pattern instead of a simple variable.
下面的示例演示如何循环一个序列,以及如何使用元组模式来代替简单变量。
The following example shows how to loop over a sequence, and how to use a tuple pattern instead of a simple variable.
下面的示例演示如何循环一个序列,以及如何使用元组模式来代替简单变量。
应用推荐