我正在替换textcrl的值(名称:控制)从另一个文本Ctrl(名称:controlz). 到目前为止我已经做到了。在
def replace(self, event):
newtext = tokenize_editor_text(self.controlz.GetValue())
text = tokenize_editor_text(self.control.GetValue())
for word in text:
if (word == misspelled_list[0]):
text[text.index(word)] = newtext
corrected = ' '.join(map(str,text))
self.control.SetValue(corrected)
print corrected
例如,当(self.controlz)
中有一个输入( Chony)
,而要替换(self.control)
中的另一个单词(choni)
,它将替换[u'chony']
。即使我也用过' '.join(map(str,text))
。我怎么能得到相同的值(chony)而不是[u'chony']
任何解决方案都值得赞赏。
非常感谢
如果在列表或元组上调用
str
,它将显示列表内部值的repr
这个电话
^{pr2}$返回一个我认为类似
[u"chony"]
的列表然后将该列表值设置为内部的列表索引
然后调用每个文本项的字符串
如果在
newtext
中始终只有一个元素,则可以只分配第0个索引相关问题 更多 >
编程相关推荐