小编Ric*_*Chu的帖子

List + = Tuple vs List = List + Tuple

假设我有这些作业:

points = []
point = (1, 2)
Run Code Online (Sandbox Code Playgroud)

我怎么做的时候:

points += point
Run Code Online (Sandbox Code Playgroud)

它工作得很好,给我分数= [1,2].但是,如果我这样做:

points = points + point
Run Code Online (Sandbox Code Playgroud)

它给了我一个TypeError:只能将列表(不是"元组")连接到列表.这些陈述不是一回事吗?

python tuples list concatenation

22
推荐指数
1
解决办法
1690
查看次数

标签 统计

concatenation ×1

list ×1

python ×1

tuples ×1