您好,登錄后才能下訂單哦!
核心代碼
# -*- 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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。