import os
flist = os.listdir('./original')
count = 1
index = open('index.txt', 'w', encoding='utf-8')
for filename in flist:
print(filename)
with open('./original/'+filename,'r', encoding='utf-8') as news:
while True:
line = news.readline().strip()
if line == '':
break
content = line.split('^')[1]
title = line.split('^')[2]
index.write(str(count)+'\t\t'+title+'\n')
with open(
'./single/single'+str(count)+'.txt','w',
encoding='utf-8') as newssplit:
newssplit.write(content+'\n')
count += 1
环球新闻数据拆分单篇不易命名,创建索引目录
最新推荐文章于 2024-08-22 22:01:15 发布