我有一个for循环,其中我有一行
我很高兴,你好吗,好吧,谢谢你
当我把它写入csv文件时,它会分成3行:
我很高兴第一排
你好 - 第二排
罚款第三排
我怎样才能将所有内容都放到第一行?
for item in soup.select('div.view-content ol li'):
with open('small.csv','a') as f1:
writer=csv.writer(f1, delimiter=' ',lineterminator='\n',)
for elm in soup.findAll("h4"):
for a in elm.findAll('a'):
texts=a.text
texts=texts.replace(",", ";")
linked=a.get('href')
link='http://www.india.gov.in'+linked
link=link.replace("http://",result+"http://")
link=link+"\n"
f1.seek(0)
writer.writerow(texts)
inFile = open('small.csv','r')
outFile = open('large.csv','w')
listLines = []
for line in inFile:
if line in listLines:
continue
else:
outFile.write(line)
listLines.append(line)
outFile.close()
inFile.close()