Printing Python version in output

前端 未结 5 1106
清歌不尽
清歌不尽 2020-11-30 17:07

How can I print the version number of the current Python installation from my script?

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 17:14

    Try

    import sys
    print(sys.version)
    

    This prints the full version information string. If you only want the python version number, then Bastien Léonard's solution is the best. You might want to examine the full string and see if you need it or portions of it.

提交回复
热议问题