Python2 to Python3 conversion tool 2to3

Source: Internet
Author: User

How to use Windows systems :

(1) Copy the 2to3.py under tools/scripts under the Python installation package to the file directory that needs to be converted.

(2) DOS switch to the file directory that needs to be converted, Run command 2to3.py test.py

Printable test.py, differences in Python2 and Python3.

(3) DOS switch to the file directory that needs to be converted, Run command 2to3.py-w test.py

To back up test.py as a Test.py.bak file

test.py the corresponding format and the corresponding package to Python3

Congratulations, Python2 to Python3. Format modified successfully.

At the same time, it may be quite unusual to greet you. For example, the following description:

Symptom 1:

Typeerror:cannot use a string pattern on a Bytes-like object

Reason:

The regular expression is a Unicode string, but read () of Urlopen () is the ascii/bytes string.

The fix here was to compile a bytes object instead of a text string.

is changed to

Regix = Compile (b' # ([\d,]+) ')

-----not finished----

Continue to learn in

Python2 to Python3 conversion tool 2to3

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.