首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

linux上获取python的版本号【备忘】

2012-12-23 
linux下获取python的版本号【备忘】?3、通过python的platform模块获取版本号$python -c import platform

linux下获取python的版本号【备忘】
>>>

?

3、通过python的platform模块获取版本号
$python -c 'import platform; print platform.python_version()'
2.5.1

?

4、通过python的sys模块获取版本号
$python -c 'import sys; print sys.version' 2>&1
2.5.1 (r251:54863, Apr 28 2009, 18:32:15)
[GCC 3.4.5 20051201 (Red Hat 3.4.5-2)]
可以通过提取相应字段获取版本号
$python -c 'import sys; print sys.version' 2>&1 | awk '$1~/[0-9]\.[0-9].*/{print $1}'

?

热点排行