合并由`re.findall()`返回的列表
这个问题在这里已经有了答案:
尝试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