python在尝试创建列表时崩溃(?)
当我试图在python中运行这段代码时,python选项卡会打开,但很快就会关闭。当我运行其他程序时,它工作正常。我不知道可能是什么问题 守则:python在尝试创建列表时崩溃(?),python,list,crash,Python,List,Crash,当我试图在python中运行这段代码时,python选项卡会打开,但很快就会关闭。当我运行其他程序时,它工作正常。我不知道可能是什么问题 守则: b = 0 c = 0 d = 0 e = 0 list1 = [9] while b != 9: print(list1) list1.append = (c, d) b += 1 e += 1 c += 200 if e == 3: e = 0 d += 200
b = 0
c = 0
d = 0
e = 0
list1 = [9]
while b != 9:
print(list1)
list1.append = (c, d)
b += 1
e += 1
c += 200
if e == 3:
e = 0
d += 200
c = 0
input()
你想达到什么目的?Append是列表的一种方法。如果要在列表末尾添加这些元素,请执行以下操作:
list1.append(c)
list1.append(d)
是这样做的正确方法之一。我们需要看到错误的说法来确定,但是
list1.append=(c,d)
,应该是list1.append(c,d)
至少。使用list1.append([c,d])
为什么在代码末尾从用户处获取输入
?@Ahmet这是一种常见的方法,用于防止在脚本未直接从命令行运行时关闭控制台。用户需要按enter键程序才能结束。我以为一半的代码都被粘贴了。我以为会有更多的代码,我把append命令改为“list1.append((c,d)),现在它工作得很好!ThanksI使用了“list1.append((c,d)”,现在它可以工作了。想要创建一个坐标列表。
list1.append(c)
list1.append(d)