Import some python3 modules in Python2

后端 未结 1 538
我寻月下人不归
我寻月下人不归 2021-01-14 00:46

Is there a way to import Python 3 modules into Python 2 scripts? I want to use some Python 3 modules in a Django application and haven\'t seen anything on the Internet. Any

相关标签:
1条回答
  • 2021-01-14 01:48

    I don't think it's really possible, no. The same instance of the interpreter has to handle every module imported in a given app, so there's no obvious way to mix and match interpreters. If you need to accomplish a discrete task with a Python 3 module, you could try making a command-line script to accomplish your task and then calling that script as a subprocess from your Python 2 app, but that would be awkward to say the least.

    Note that I don't think there are really a whole lot of Python 3-only modules -- most modules at this point either support both versions, or only Python 2.

    0 讨论(0)
提交回复
热议问题