合并由`re.findall()`返回的列表

这个问题在这里已经有了答案:

  • Python中的append和extend列表方法之间的区别22回答

  • 尝试reduce(sum, line)

    def extractDollar(line): 
            global mainList
            temp=[]
    
            #lowercasing all the string
            line=line.lower()
    
            #storing all word starting with $ in a line in temp
            #then adding that  to existing list mainList
            #to form a single list and removing empty value
            temp= re.findall(r'$w+',line)
    
            mainList=mainList+[j for i in zip(mainList,temp) for j in i]
            mainList= filter(None, mainList)
    
            return reduce(sum,line)
    
    链接地址: http://www.djcxy.com/p/22559.html

    上一篇: Combine the list returned by `re.findall()`

    下一篇: Add a string to a Python list