Python有几种不同的实现: CPython、Jython、PyPy等等。我想通过编程的方式来确定我的代码运行在哪个实现上。我该怎么做呢?
具体地说,请为我编写一个名为get_implementation_name()的函数:
impl_name = get_implementation_name()
if impl_name == "CPython":
print "I can abuse CPython implementation details. (I'm a bad, bad man.)"
elif impl_name == "PyPy":
print "Can't count on reference-counting garbage collection here..."
else:
print "I better be careful..."发布于 2013-02-06 06:25:20
In [50]: import platform
In [52]: platform.python_implementation()
Out[52]: 'CPython'发布于 2013-02-06 06:26:33
platform怎么样?
它能给你
platform.python_implementation()https://stackoverflow.com/questions/14718135
复制相似问题