Printing Python version in output Printing Python version in output python python

Printing Python version in output


Try

import sysprint(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.


import platformprint(platform.python_version())

This prints something like

3.7.2


Try

python --version 

or

python -V

This will return a current python version in terminal.


matomo