我可以检测到我的代码是在cPython还是Jython上运行? [英] Can I detect if my code is running on cPython or Jython?
问题描述
我正在开发一个小型django项目,稍后将部署在一个servlet容器中。但是,如果我使用cPython而不是Jython,开发速度要快得多。所以我想做的是测试我的代码是否在我的settiings.py中的cPython或Jython上运行,所以我可以告诉它使用适当的db驱动程序(postgresql_psycopg2或doj.backends.zxjdbc.postgresql)。有没有一个简单的方法?
I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backends.zxjdbc.postgresql). Is there a simple way to do this?
推荐答案
如果你正在运行Jython
if you're running Jython
import platform
platform.system()
返回'Java'
这里有一些讨论,希望这有帮助。
return 'Java'
here has some discussion, hope this helps.
这篇关于我可以检测到我的代码是在cPython还是Jython上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!