Data type conversions for Python

Source: Internet
Author: User

One

To force type conversions:

Factory functions are generally available when specific conditions are met

List ()

STR ()

Tuple ()

......

Convert the data type to the type you want

1. Cast the number to a string:

Number---STR:

STR (number)

Two

Python3 in bytes and str Conversion of:

---Bytes STR:

E1:str (byte,encoding= "UTF8")

E2:bytes.decode (b)

STR--Bytes:

E1:bytes (str,encoding= "UTF8")

E2:str.encode (bytes)

Three

Conversion of Utf-8 and Unicode: (str-->bytes)

Utf-8 decoding to Unicode:

Utf-8--------Decode (' utf-8 ')------> Unicode

Unicode encoding is utf-8:

Utf-8 <--------encode (' utf-8 ')-----utf-8





Data type conversions for Python

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.