6

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/

次のように文字を一括置換する必要があります

a > q

q > a

[/0] > 0 

! > 1

といくつかの他の

置換する文字のテーブルを作成することはできますか? 私は少し初心者で、Notepad++ でスクリプトを実行できるかどうかわかりません

4

3 に答える 3

0

というわけで、AZERTYのレイアウトにはかなりの種類があり、これが完全な答えではありません。ただし、テストケースに合格し、Pythonで実行できる単一の文字置換と同じくらい高速に実行します(Unicodeも考慮する必要がない限り)

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)

したがって、ユーザーが使用している AZERTY のバージョンがわかれば問題ありません。変換テーブルに AZERTY 実装の詳細を正しく記入してください。

于 2013-08-13T05:41:54.160 に答える
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

必要に応じて replace_dict 変数をカスタマイズするだけです。

于 2013-08-13T04:55:03.700 に答える