如何在记事本 rt++ 中使用 python 删除特定字符

How to delete a specific characters using python in notepad rt++

所以我一直在使用 github 的程序,它允许我在记事本 rt ++ 中自动输入,但存在一个问题,记事本 rt++ 在每个单词之间添加“4”。

所以你能帮我做一个(Python)程序,自动删除句子中的数字“4”吗

您好,您可以使用正则表达式更改 Python 中的任何字符串。

首先导入re库:

import re

然后你可以使用 sub 函数来更改任何字符串或任何文本文件甚至抓取..

例如:

str = "This is a simple test 4 regex"
str_change = re.sub(r'4 ', '', str)
print(str_change)

输出:

This is a simple test regex