How do I check what version of Python is running my script?

前端 未结 22 2053
醉话见心
醉话见心 2020-11-22 04:11

How can I check what version of the Python Interpreter is interpreting my script?

22条回答
  •  旧巷少年郎
    2020-11-22 04:45

    from sys import version_info, api_version, version, hexversion
    
    print(f"sys.version: {version}")
    print(f"sys.api_version: {api_version}")
    print(f"sys.version_info: {version_info}")
    print(f"sys.hexversion: {hexversion}")
    

    output

    sys.version: 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
    sys.api_version: 1013
    sys.version_info: sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
    sys.hexversion: 50726384
    

提交回复
热议问题