标签:io for sp 2014 c on r amp linux
1 在linux命令行底下通过python -V查看python版本号
suiyc@suiyc-A76GMV:~/sycworkspace/simple-sample$ python -V 2>&1 | awk ‘{print $2}‘
输出结果示例:2.7.3
2 直接在命令行中输入python
示例:
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模版获取版本号
suiyc@suiyc-A76GMV:~/sycworkspace/simple-sample$ python -c ‘import platform; print platform.python_version()‘
2.7.3
4 通过python的sys模块获取版本号
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]
可以通过提取相应字段获取版本号
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.3
标签:io for sp 2014 c on r amp linux
原文地址:http://my.oschina.net/syc2013/blog/324845