核心代码
# -*- coding: utf-8 -*- ''' python读取英文文件,将每个单词按照空格分开,并将每个单词独自放一行 ''' def dcfenhang(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() dcfenhang("jb51.txt","fenci.txt")
jb51.txt文件
welcome to visit jb51.net
Thans very much
效果如下图所示
这篇文章就介绍到这了,希望大家以后多多支持亿速云。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。