Get a list of all the encodings Python can encode to

后端 未结 9 1291
暗喜
暗喜 2020-11-28 03:19

I am writing a script that will try encoding bytes into many different encodings in Python 2.6. Is there some way to get a list of available encodings that I can iterate ove

9条回答
  •  醉酒成梦
    2020-11-28 04:11

    The Python source code has a script at Tools/unicode/listcodecs.py which lists all codecs.

    Among the listed codecs, however, there are some that are not Unicode-to-byte converters, like base64_codec, quopri_codec and bz2_codec, as @John Machin pointed out.

提交回复
热议问题