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

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

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

22条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 04:52

    With six module, you can do it by:

    import six
    
    if six.PY2:
      # this is python2.x
    else:
      # six.PY3
      # this is python3.x
    

提交回复
热议问题