[python]rot13练习
code: def rot13 ( s ) : intab = '' outtab = '' for a in range ( ord ( 'A' ) , ord ( 'Z' ) + 1 ) : intab += chr ( a ) for a in range ( ord ( 'a' ) , ord ( 'z' ) + 1 ) : intab += chr ( a ) for b in range ( ord ( 'N' ) , ord ( 'Z' ) + 1 ) : outtab += chr ( b ) for b in range ( ord ( 'A' ) , ord ( 'N' ) ) : outtab += chr ( b ) for b in range ( ord ( 'n' ) , ord ( 'z' ) + 1 ) : outtab += chr ( b ) for b in range ( ord ( 'a' ) , ord ( 'n' ) ) : outtab += chr ( b ) trantab = str . maketrans ( intab , outtab ) return s . translate ( trantab ) if __name__ == '__main__' : s1 = 'Yvsr vf cngurgvp, yrg\'f