The __future__ of Python module learning

Source: Internet
Author: User

After each program has been updated, it will be changed compared to the previous version. These changes will cause the user of the program to be a little trouble!

For example, python2.xx and 3.xx changes, enough to make the novice head big!

In 3,

U ' xxx ' and ' xxx ' are both string types (3 kinds of keywords are changed to class, headache!) )

B ' xxx ' denotes byte type

In 2 species,

U ' xxx ' type is unicode,b ' xxx ' is a string type

It's so dizzy! Pay attention to the difference between 3 and 2 every time!

So, the __future__ module appeared! For changes of 3 and 2 text types, just add the following at the beginning of the module:

From __future__ import unicode_literals

Then do not worry about 2 and 3 will appear text-related errors!

The __future__ of Python module learning

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.