当前位置: 首页 > 工具软件 > CPython > 使用案例 >

判断cpython与pypython

林俊晖
2023-12-01

判断cpython与pypython

try:
    from platform import python_implementation
except ImportError: # pragma: no cover
    def python_implementation():
        """Return a string identifying the Python implementation."""
        if 'PyPy' in sys.version:
            return 'PyPy'
        if os.name == 'java':
            return 'Jython'
        if sys.version.startswith('IronPython'):
            return 'IronPython'
        return 'CPython'
    

if __name__ == "__main__":
    python_version = python_implementation()

    print("The version of your python is ",python_version)

参考链接:https://zhuanlan.zhihu.com/p/264111797

 类似资料: