简体   繁体   中英

How to call 2to3 in Python?

Is there a way I could convert a python2 string to a python3 string by calling 2to3 in python without having to call it via command line?

input = 'a=raw_input()'
output = 'a=input()'

2to3 is open source:

https://github.com/python/cpython/tree/3.10/Lib/lib2to3/

The refactor_string function is what you're looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM