【发布时间】:2016-01-30 00:12:27
【问题描述】:
我有这个问题,我期待看到您的积极回答和解决方案。 代码如下:当程序在文本拆分后检测到拼写错误的单词时 它将每个拼写错误的单词附加到列表中 [a] 现在我的问题是,我怎样才能将拼写错误的单词写入(更新)到字典中,以使字典中的每一行只包含一个单词。到目前为止,我已经尝试过,它只写入当前插入并删除以前的记录。任何帮助表示赞赏(谢谢)
def onaddbutton(self,event):
os.chdir('d:/KKSC')
dic = getDic()
print dic[0], dic[1], dic[2]
text = tokenize_editor_text(self.controlz.GetValue())
a = []
for word in text:
if word not in dic:
misspelled = word
a.append(misspelled)
f= (misspelled)
with open('test.text', encoding='utf-8', mode='w') as f:
f.write(misspelled)
f.write('\n')
f.seek(0)
print(repr(f.readline()[:1]))
【问题讨论】:
-
请更正代码的缩进。当前版本存在语法错误。
标签: python python-2.7 python-3.x wxpython