核心代码
#-* -编码: utf-8-* -
“”'
python读取英语文件,为每个单词留出一个空格,为每个单词放置一行
“”'
defdcfenhang(infile,outfile ) :
infopen=open(infile,' r ',encoding='utf-8 ' ) )
outopen=open(outfile,' w ',encoding='utf-8 ' ) )
lines=infopen.readlines (
for line in lines:
for db in line.split () :
if db not in outfile:
outopen.write(db'n ' ) )。
infopen.close (
outopen.close (
Cfenhang(JB51.txt,) fenci.txt ) )。
jb51.txt文件
欢迎使用visit jb51.net
Thans very much
效果如下图所示
这篇文章介绍到这里了。 希望今后能多支持容易录用的站长站。