[Python] Character Translation using Python (like the tr command)

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    Is there a way to do character translation / transliteration (kind of like the tr command) using Python?

    Some examples in Perl would be:

    my $string = "some fields";
    $string =~ tr/dies/eaid/;
    print $string; # domi failed

    $string = 'the cat sat on the mat.';
    $string =~ tr/a-z/b/d;
    print "$string\n"; # b b b. (because option "d" is used to delete characters not replaced)

    Continue reading...

Compartilhe esta Página