Get the version number of Python under Linu

Source: Internet
Author: User

1 View the Python version number at the bottom of the Linux command line via Python-v

[Email protected]:~/sycworkspace/simple-sample$ python-v 2>&1 | awk ' {print $} '

Output Results Example: 2.7.3

2 Enter Python directly on the command line

Example:
[Email protected]:~/sycworkspace/simple-sample$ python
Python 2.7.3 (Default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "Help", "copyright", "credits" or "license" for more information.

3 Get the version number via Python's platform template

[Email protected]:~/sycworkspace/simple-sample$ python-c ' import platform; Print platform.python_version () '
2.7.3

4 Get the version number through the SYS module of Python

[Email protected]:~/sycworkspace/simple-sample$ python-c ' Import sys; Print Sys.version ' 2>&1
2.7.3 (Default, Feb 27 2014, 19:58:35)
[GCC 4.6.3]

You can get the version number by extracting the appropriate fields
[Email protected]:~/sycworkspace/simple-sample$ python-c ' Import sys; Print Sys.version ' 2>&1 | awk ' $1~/[0-9]. [0-9].*/{print} '
2.7.3

Get the version number of Python under Linu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.