|
# -*- coding: GBK -*-
# -*- coding: utf-8 -*-
#遇到文中的空格就换行
def delblankline(infile, outfile):
infopen = open(infile, 'r',encoding="utf-8")
outfopen = open(outfile, 'w',encoding="utf-8")
infopen = open(infile, 'r',encoding="GBK")
outfopen = open(outfile, 'w',encoding="GBK")
db = infopen.read()
outfopen.write(db.replace('? Q','\n'))
outfopen.write(db.replace(' SH','\n'))
outfopen.write(db.replace(' SZ','\n'))
infopen.close()
outfopen.close()
delblankline("重点低开个股.txt", "o3.txt")
怎么改好啊
原文本是这样的
? QSH600540 SH600766 SH600988 SH601038 SH601330 SH603106 SH603738 SH603819 SZ000035 SZ002237 SZ002848 SZ002939 SZ002945 SZ300029 SZ300105 SZ300210 SZ300460 SZ300536 SZ300768
想要的结果:
600540
600766
600988
601038
601330
603106
603738
603819
000035
002237
002848
002939
002945
300029
300105
300210
300460
300536
300768
是这样排下去。有什么更好的方法吗?
|
|