0
我有一个UNICODE格式5000个单词的列表。 如何在添加新单词后对它们进行排序?python排序文本文件中的单词列表(test.txt)
a = []
for word in text:
if word not in dic:
misspelled = word
a.append(misspelled)
foo =misspelled
f = open('test.txt', 'a')
f.write(foo.encode('utf8'))
x='\n'
f.write(x.encode('utf8'))
f.close()
我,但是当我打开文本文件我没有看到变化和新的字被插入到列表@padraic –
@BamoNabaz的最后一行,也就是'了'呢,则追加到一个文件 –
我读了OP的代码和你的,OP似乎有一个额外的'f.write(x.encode('utf8'))''。它甚至需要吗? –