1 在linux命令行底下經過python -V查看python版本號python
suiyc@suiyc-A76GMV:~/sycworkspace/simple-sample$ python -V 2>&1 | awk '{print $2}'linux
輸出結果示例:2.7.3ui
2 直接在命令行中輸入pythonspa
示例: suiyc@suiyc-A76GMV:~/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 經過python的platform模版獲取版本號orm
suiyc@suiyc-A76GMV:~/sycworkspace/simple-sample$ python -c 'import platform; print platform.python_version()' 2.7.3it
4 經過python的sys模塊獲取版本號io
suiyc@suiyc-A76GMV:~/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]form
能夠經過提取相應字段獲取版本號 suiyc@suiyc-A76GMV:~/sycworkspace/simple-sample$ python -c 'import sys; print sys.version' 2>&1 | awk '$1~/[0-9].[0-9].*/{print $1}' 2.7.3import