The magical _python of Python encode and decode

Source: Internet
Author: User
Tags base64 bz2 rfc

>>> "Hello". Encode ("hex")
' 68656c6c6f '

The corresponding can also

>>> ' 68656c6c6f ' decode ("hex")
' Hello '

I checked the manuals, and these codec are available.

Codec

Aliases

Operand type

Purpose

Base64_codec Base64, base-64 byte string Convert operand to MIME base64
Bz2_codec bz2 byte string Compress the operand using bz2
Hex_codec Hex byte string Convert operand to hexadecimal representation, with two digits per byte
Idna Unicode string Implements RFC 3490. New in version 2.3. Also Encodings.idna
Mbcs Dbcs Unicode string Windows Only:encode operand According to the ANSI codepage (CP_ACP)
PalmOS Unicode string Encoding of PalmOS 3.5
Punycode Unicode string Implements RFC 3492. New in version 2.3.
Quopri_codec Quopri, Quoted-printable, quotedprintable byte string Convert operand to MIME quoted printable
Raw_unicode_escape Unicode string Produce a string this is suitable as raw Unicode literal in python source code
Rot_13 Rot13 Unicode string Returns the Caesar-cypher encryption of the operand
String_escape byte string Produce a string, is suitable as string literal in python source code
Undefined Any Raise an exception to all conversions. Can be used as the system encoding if no automatic coercion between byte and Unicode strings is desired.
Unicode_escape Unicode string Produce a string, is suitable as Unicode literal in python source code
Unicode_internal Unicode string Return the internal representation of the operand
Uu_codec Uu byte string Convert the operand using uuencode
Zlib_codec Zip, zlib byte string Compress the operand using gzip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.