/ /数値を増やすPython - python、plugins、notepad ++

数値を増やすPython - python、プラグイン、notepad ++

申し訳ありませんが、私は約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.

私はnotepadd ++でpythonプラグインを試してみましたが、動作しませんでした。また、メモ帳のオプション列エディタ(alt + c)も知っていますが、10.000語を選択することはできません。

¿notepadd ++でこのタスクをpythonでどのように処理できますか?

読んでくれてありがとう

回答:

回答№1は0

whileループを次のように置き換えます。

split_content = content.split("n")  #split content into sentences by the newline

new_content = ""

for sentence in split_content:  #split sentence into words
for word in sentence.split(" "):
if word == "printing":
new_content += "printing-%s " % (number)
number += 1
else:
new_content += word + " "

new_content += "n"  #put newlines back in to keep original formatting

私はちょうど質問するコードを理解するのに役立つ必要があります!