Layout 批量替换单个文本文件中的字符串(记事本+;+;)

Layout 批量替换单个文本文件中的字符串(记事本+;+;),layout,notepad++,Layout,Notepad++,我正在使用记事本++编辑一个编码不好的文本文件。该程序没有考虑用户的AZERTY键盘布局。结果是一个文本文件,如下所示(示例I) 还有其他一些 是否可以创建要替换的字符表?我是一个初学者,我不知道记事本++是否允许运行脚本我不知道记事本++。但是如果您的机器中安装了python,您可以使用这个小脚本 source = """Hi guysm this is Qqron< I zonder zhen ze

我正在使用记事本++编辑一个编码不好的文本文件。该程序没有考虑用户的AZERTY键盘布局。结果是一个文本文件,如下所示(示例I)

还有其他一些


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

我不知道记事本++。但是如果您的机器中安装了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
source=“”你好,我是Qqron<
我宗德振泽cqn一起去游泳池
:y phone nu;ber是!%%)@!#@@(
Cqll;e/“”“
替换_dict={'a':'q','q':'a','[/0]':'0','!':'1'}
目标=“”
对于源中的字符:
target\u char=替换\u dict.get(char)
如果目标字符:
目标+=目标字符
其他:
目标+=字符
打印目标

只需定制replace_dict变量以满足您的需要。

因此,有很多不同类型的AZERTY布局,因此这不是一个完整的答案。但是,它确实通过了测试用例,并且与python中的任何单字符替换一样快(除非您也需要考虑)

从字符串导入maketrans
测试=''你好,我是Qqron<
我宗德振泽cqn一起去游泳池
:y phone nu;ber是!%%)@#@@#(
Cqll;e/“”
#警告:表未满。

table=maketrans('aqqzwzw;:!@$%^&*()m/Notepad++有一个宏记录器,但是宏不能用任何有文档记录的嵌入式语言编写。您可以记录一个执行70左右搜索和替换操作的宏。请参阅。有一些关于“破解”宏语言的信息

显然,记事本++不适用于此任务。Python解决方案还可以,但Perl最初适用于类似的内容。这里有一行代码。这是针对Windows的。在bash/Linux中,将双引号替换为单引号

perl -n -e "tr/aqAQzwZW;:!@#$%^&*()m\/</qaQAwzWZmM1234567890:?./;print"
perl-n-e“tr/aqzwzw;:!@$%^&*()m\/
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
from string import maketrans

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

# warning: not a full table.  
table = maketrans('aqAQzwZW;:!@#$%^&*()m/<', 'qaQAwzWZmM1234567890:?.')

test.translate(table)
perl -n -e "tr/aqAQzwZW;:!@#$%^&*()m\/</qaQAwzWZmM1234567890:?./;print"