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

前端 未结 5 690
夕颜
夕颜 2020-12-08 11:11
>>> myList[1]
\'from form\'
>>> myList[1].append(s)

Traceback (most recent call last):
  File \"\", line 1, in 
          


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-08 11:38

    What you are trying to do is add additional information to each item in the list that you already created so

        alist[ 'from form', 'stuff 2', 'stuff 3']
    
        for j in range( 0,len[alist]):
            temp= []
            temp.append(alist[j]) # alist[0] is 'from form' 
            temp.append('t') # slot for first piece of data 't'
            temp.append('-') # slot for second piece of data
    
        blist.append(temp)      # will be alist with 2 additional fields for extra stuff assocated with each item in alist  
    

提交回复
热议问题