AttributeError: 'tuple' object has no attribute 'append'

前端 未结 3 1546
心在旅途
心在旅途 2021-01-20 02:20

Can anyone help me with this code?

Jobs = ()
openFile = open(\'Jobs.txt\')
x = 1
while x != 0:
    Stuff = openFile.readline(x)
    if Stuff != \'\':
                


        
3条回答
  •  感动是毒
    2021-01-20 02:51

    The Jobs object you created is a tuple, which is immutable. Therefore, you cannot "append" anything to it.

    Try

    Jobs = []
    

    instead, in which you create a list object.

提交回复
热议问题