简体   繁体   English

在3.x程序中有条件地将python代码的某些部分作为2.x执行

[英]Conditionally executing some part of python code as 2.x in a 3.x program

There is an option of __future__ to import modules from python 3.x into 2.x venv. __future__选项可以将模块从python 3.x导入2.x venv。 Is there a similar option that allows 2.x code to be run in 3.x venv. 是否有类似的选项允许2.x代码在3.x venv中运行。

Some thing like 就像是

__use2.x__:
   #2.x code block

#back to 3.x code 

This is to be used to merge codes from different versions while upgrading to a higher level of python. 这用于合并来自不同版本的代码,同时升级到更高级别的python。

There are several modules that may prove helpful (hard to say which is best or how to do it, without knowing anything about the code you are talking about). 有几个模块可能被证明是有用的(很难说哪个是最好的或如何做的,而不知道您正在谈论的代码的任何信息)。 But for starters I'd recommend: 但对于初学者,我建议:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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