Python 3 文档在其 codecs page 中列出了 rot13 .
我尝试使用 rot13 编码对字符串进行编码:
import codecs
s = "hello"
os = codecs.encode( s, "rot13" )
print(os)
这给出了
unknown encoding: rot13
错误。有没有不同的方式来使用内置的 rot13 编码?如果此编码已在 Python 3 中删除(如 Google 搜索结果所示),为什么它仍列在 Python3 文档中?
最佳答案
在 Python 3.2+ 中,有 rot_13
str-to-str codec :
import codecs
print(codecs.encode("hello", "rot-13")) # -> uryyb
关于python - 如何在 Python3 中进行 ROT13 编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10576347/