[英]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?有没有一种方法可以通过在 python 中调用
2to3
将 python2 字符串转换为 python3 字符串,而无需通过命令行调用它?
input = 'a=raw_input()'
output = 'a=input()'
2to3
is open source: 2to3
是开源的:
https://github.com/python/cpython/tree/3.10/Lib/lib2to3/ https://github.com/python/cpython/tree/3.10/Lib/lib2to3/
The refactor_string
function is what you're looking for. refactor_string
function 就是您要查找的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.