【发布时间】:2017-06-08 02:55:58
【问题描述】:
是否有可能有 python 3.x 代码并在其中执行 2.x 代码(例如函数调用)?
#Code written in python 3.x
.
.
.
.
.
.
#This is the python 2.x part with Function2x() written in python 2.x
Function2x()
#End of python 2.x part
#Code written in python 3.x
.
.
.
.
.
.
这会被认为是不好的做法吗?如果是这样,如果将代码从 3.x 移植到 2.x 不是一种选择,如何规避这个问题?
【问题讨论】:
-
它可以帮助您将您的脚本从 2 转换为 3 docs.python.org/3.0/library/2to3.html
标签: python python-2.7 python-3.x python-3.5 python-2.x