Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Bulk Posting on Facebook Pages using Selenium
Next article icon
We can convert Python2 scripts to Python3 scripts by using2to3 module. It changes Python2 syntax to Python3 syntax. We can change all the files in a particular folder from python2 to python3.

Installation

This module does not come built-in with Python. To install this type the below command in the terminal.
pip install 2to3
Syntax:
2to3 [file or folder] -w
If we want to change all files in the currently open folder and all the files in the subfolder from Python2 to Python3 type the below command.
2to3.-w
If we want to change a particular file in the current folder from Python2 to Python3 then enter the following command.
2to3 gfg.py -w
Example: Consider a simple Python2 file.python-2to3To convert this file from Python2 to Python3 open the terminal in the directory containing the file and type the below command.python2to3The Python file will now be converted to Python3. Let's see the file.Python-2to3

Automate the Conversion from Python2 to Python3
Improve
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp