txt 텍스트의 공백 제거

3371 단어 nlp
temp=[]
with open(' /end/task_1_hxj.txt',encoding='utf-8') as f,open(' /end/hxj.txt','w',encoding='utf-8') as fw:
    #f_csv = csv.reader(f)
    for line in f:
         if line.split():
                line = "".join(line.split())
                try:
                    line = line.split(':')[1]
                except:
                    print(line)
                    pass
                if len(line)>0:
                    temp.append(line)
                    fw.write(line)
                    fw.write('
'
)

좋은 웹페이지 즐겨찾기