(Python)区分PyPy、Jython、IronPython、CPython解释器

        使用以下代码区分电脑中PyPy、Jython、IronPython、CPython等Python解释器类型。

try:
    from platform import python_implementation
except ImportError:
    # Unable to import
    def python_implementation():
        # Return a string identifying the Python implementation
        # PyPy
        if 'PyPy' in sys.version:
            return 'PyPy'
        # Jython
        if os.name == 'java':
            return 'Jython'
        # IronPython
        if sys.version.startswith('IronPython'):
            return 'IronPython'
        # CPython
        return 'CPython'
    
if __name__ == "__main__":
    python_version = python_implementation()
    print(f'The version of your python is {python_version}! ')

 

Reference:

如何判断python解释器是哪一个 - 知乎

你可能感兴趣的:(Python,python,java,开发语言)