在单个文本文件中批量替换字符串(Notepad ++)

use*_*801 6 layout notepad++

我正在使用Notepad ++编辑一个编码很差的日志文本文件.该程序没有考虑用户的AZERTY键盘布局.结果是一个文本文件如下(我组成的例子)

Hi guysm this is Qqron<
I zonder zhen ze cqn go to the szi;;ing pool together
:y phone nu;ber is !%%)@!#@@#(
Cqll ;e/
Run Code Online (Sandbox Code Playgroud)

我需要按如下方式批量替换字符

a > q

q > a

[/0] > 0 

! > 1
Run Code Online (Sandbox Code Playgroud)

还有其他几个

是否可以创建要替换的字符表?我是一个初学者,我不知道Notepad ++是否允许运行脚本

小智 0

我不知道Notepad++。但是如果你的机器上安装了 python,你就可以使用这个小脚本。

source = """Hi guysm this is Qqron<                                           
I zonder zhen ze cqn go to the szi;;ing pool together                         
:y phone nu;ber is !%%)@!#@@#(                                                
Cqll ;e/"""                                                                   

replace_dict = {'a': 'q', 'q': 'a', '[/0]': '0', '!': '1'}                    

target = ''                                                                   
for char in source:                                                           
    target_char = replace_dict.get(char)                                      
    if target_char:                                                           
        target += target_char                                                 
    else:                                                                     
        target += char                                                        

print target
Run Code Online (Sandbox Code Playgroud)

只需自定义 Replace_dict 变量即可满足您的需要。