Python_py2 and Py3 Read and write text differences

Source: Internet
Author: User

The difference between Python2 and Python3?

Python 2 str corresponds to Python3 bytes

Python 2 uincode corresponds to Pyhon3 str

Py2 strings are directly 2 binary, Unicode encoding requires a front plus u

Py3 2 binary requires a front plus b

Text Read and write differences?

Py2 characters can be written directly to the file, Unicode needs to encode, then write to the file, read the file, need to decode

Py3 Open file, specify encoding format for automatic encoding, write to file without encoding and decoding

Python_py2 and Py3 Read and write text differences

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.