0

在基于 python 的项目中,我想使用功能数据类和库,例如当前的 RxPY 版本。

但是,我们绑定到只有 Python 3.5.5 的环境(Yocto 系统)

从 TypeScript/JavaScript 我知道某些语言允许将代码转换为较低的语言版本。

可以将 Python 3.7 代码转换为较低版本吗?

非常感谢

4

1 回答 1

1

You can't just use a tool to convert Python code to earlier versions, because those versions would sometime lack the libraries that you need. Using Python 3.7's dataclass is a good example.

A workaround for you would be to just install a port of dataclasses back in your 3.5 environment. This would be tricky. If you had python 3.6 you could just install this through

pip install dataclasses

But you can see in this issue that they never ported it back for python 3.5. If you check out their GitHub, maybe there are manual changes you could do to the source code to make it work. Maybe.

The easier way would be to find an alternative to dataclasses

于 2019-11-21T07:42:26.033 回答