Python read from file and remove non-ascii characters
问题 I have the following program that reads a file word by word and writes the word again to another file but without the non-ascii characters from the first file. import unicodedata import codecs infile = codecs.open('d.txt','r',encoding='utf-8',errors='ignore') outfile = codecs.open('d_parsed.txt','w',encoding='utf-8',errors='ignore') for line in infile.readlines(): for word in line.split(): outfile.write(word+" ") outfile.write("\n") infile.close() outfile.close() The only problem that I am