➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 petri.lehtinen
收信人 cool-RR, ezio.melotti, petri.lehtinen
日期 2011-12-14.09:30:35
SpamBayes Score 1.5101531e-11
Marked as misclassified 否
Message-id <1323855036.52.0.167594584134.issue13600@psf.upfronthosting.co.za>
In-reply-to
内容
Ram Rachum wrote:
> The `rot_13` codec is supposed to work like this, no?

No it isn't. In Python 3, str.encode() always encodes to bytes and bytes.decode() always decodes to str. IOW, str.encode() encodes text (Unicode) to data (bytes), and bytes.decode() decodes data to text. ROT-13 is not a character encoding, so it cannot be used in this manner.

It's still available in the codecs module, though:

>>> import codecs
>>> codecs.lookup('rot-13').encode('qwerty')
('djregl', 6)

Other text->text and bytes->bytes codecs are also available there.
历史
日期 用户 动作 参数
2011-12-14 09:30:36petri.lehtinen修改recipients: + petri.lehtinen, ezio.melotti, cool-RR
2011-12-14 09:30:36petri.lehtinen修改messageid: <1323855036.52.0.167594584134.issue13600@psf.upfronthosting.co.za>
2011-12-14 09:30:35petri.lehtinen链接issue13600 messages
2011-12-14 09:30:35petri.lehtinen创建