【发布时间】:2016-05-26 08:40:06
【问题描述】:
抱歉,我研究了大约 1 天,但我没有找到解决方案。
我有这个代码,但不能工作
number = 1
content = editor.getText()
while "printing" in content:
content = content.replace("printing", "printing-")
number += 1
notepad.new()
editor.addText(content)
我想用增加的数字替换文件中的 10.000 个单词。
例子
来自:
Lorem Ipsum is simply dummy text of the printing
Other example text is simply from user any
Lorem Ipsum is simply dummy text of the printing
Other example text is simply from user roger
Lorem Ipsum is simply dummy text of the printing
Other example text is simply from user milton
到:
Lorem Ipsum is simply dummy text of the printing-1
Other example text is simply from user any
Lorem Ipsum is simply dummy text of the printing-2
Other example text is simply from user roger
Lorem Ipsum is simply dummy text of the printing-3
Other example text is simply from user milton
所需的词是 printing-1, printing-2, print-3,... 到 printing-10000。
我在 notepad++ 中尝试使用 python 插件但不起作用,我也知道 notepad++ 中的选项列编辑器 (alt+c) 但我无法选择 10.000 个单词。
¿如何在 notepadd++ 中使用 python 处理此任务?
感谢阅读
【问题讨论】:
-
“不工作”是什么意思?
-
content = content.replace("printing", "printing-" + str(number)) -
问题是所有替换词是:printing-1,printing-1,printing-1...应该是printing-1,printing-2,printing-3...等我用你写的最后一个代码测试结果是一样的。