如何查看输出python版本号的当前版本号

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
最近,想在我的YouMoney(http://co/p/youmoney/)里面增加提取用户操作系统版本信息。比如windows用户,可能要返回Windows
XP ,或者Windows 2003, 苹果用户应该返回Mac OS X
10.5.8。用了很多办法,包括在mac系统里调用系统命令,取环境变量,等等。最后无意发现,原来python里里面有个platform模块就可以干这件事情。省事啊!&&&&
mac上这么干 localhost:~ apple$ pythonPython 2.5.1 (r251:54863, Jun 17 2009,
20:37:34) [GCC 4.0.1 (Apple Inc. build 5465)] on darwinType "help",
"copyright", "credits" or "license" for more information.&&& import
platform&&& platform.mac_ver()('10.5.8', ('', '', ''),
'i386')&&& platform.version()'Darwin Kernel Version 9.8.0: Wed
Jul 15 16:55:01 PDT 2009; root:xnu-~1/RELEASE_I386'&&&
platform.platform()'Darwin-9.8.0-i386-32bit'&&&
platform.system()'Darwin'&&&&基本上用platform.platform()就足够了。如果是在windows上,专门还有个platform.win32_ver()
阅读(2192)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Python获取操作系统版本信息',
blogAbstract:'来源:/collect/Python-35-6.html最近,想在我的YouMoney(http://co/p/youmoney/)里面增加提取用户操作系统版本信息。比如windows用户,可能要返回Windows \r\nXP ,或者Windows 2003, 苹果用户应该返回Mac OS X \r\n10.5.8。用了很多办法,包括在mac系统里调用系统命令,取环境变量,等等。最后无意发现,原来python里里面有个platform模块就可以干这件事情。省事啊!&&&& \r\nmac上这么干 localhost:~ apple$ pythonPython 2.5.1 (r251:54863, Jun 17 2009, \r\n20:37:34) ',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:3,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}Welcome to Python.org
Get Started
Whether you're new to programming or an experienced developer, it's easy to learn and use Python.
Python source code and installers are available for download for all versions! Not sure which version to use? .
Documentation for Python's standard library, along with tutorials and guides, are available online.
Looking for work or have a Python related position that you're trying to hire for? Our relaunched community-run job board is the place to go.
Latest News
2017-08-09
2017-07-25
2017-07-17
2017-07-08
2017-06-18
Upcoming Events
2017-08-13
2017-08-17
2017-08-17
2017-08-23
2017-08-26
Success Stories
by Tim Fortenberry
Use Python for&
Web Development:
GUI Development:
Scientific and Numeric:
Software Development:
System Administration:
&&& : The future of Python is discussed here.
The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to support and facilitate the growth of a diverse and international community of Python programmers.19043人阅读
python(35)
pip 是一个安装和管理 Python 包的工具
, 是 easy_install 的一个替换品。
pip freeze可以查看已经安装的python软件包和版本
pip list 也可以
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:252567次
积分:6240
积分:6240
排名:第3931名
原创:397篇
转载:46篇
(10)(4)(10)(1)(1)(3)(3)(5)(17)(19)(20)(11)(18)(16)(27)(14)(16)(18)(3)(13)(18)(25)(37)(12)(22)(16)(20)(5)(3)(6)(17)(7)(26)条目一:知道你现在用的Python是哪个版本
在这本书里,主要实例的代码是Python3.4(发布于日)的语法。这本书也提供一些Python2.7(发布于2010年七月3日)语法的例子去强调不同之处。我的大部分建议都可应用到流行的Python运行时库:CPython, Jython, IronPython, PyPy, etc.
很多计算机预装了多个版本的标准CPython运行时库。然而,命令行中默认的python并不清晰。python通常是python2.7的别名,但是有时候它也是一些更老的版本的别名,如:python2.6或者python2.5。去明确你现在用的是哪个python的版本,又可以用--version标识。
$ python --version
Python 2.7.8
Python3通常的名字为python3
$ python3 --version
Python 3.4.2
通过检测sys内含模块中的值,你也可以弄清楚你正在使用的运行时的Python版本:
import sys
print(sys.version_info)
print(sys.version)
sys.version_info(major=3, minor=4, micro=2, releaselevel=&final&, serial=0)
3.4.2 (default, Oct 19 :17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)]
Python 2和Python 3都是被Python社区维护。除了bug修复,安全性提升和使得从Python2到Python3的反向移植更容易外,Python2的开发工作已经冻结。帮助工具,比如2to3和six的存在,使得更容易去接受Python3的向前发展。
Python3中不断添加的新功能和改进是不会再添加到Python2中的。在写这本书时,主要的Python开源库,大部分都已经与Python3兼容。我强烈地鼓励你在下一个项目中使用Python3。
想想和记下来
有两个主要的Python版本是仍然活跃的:Python 2 和 Python 3;
有多个流行的Python运行时库:CPython, Jython, IronPython, PyPy,等等;
确保在你系统的命令行运行Python时,是你预期的Python版本;
在你下一个项目中,优先选择Python3,因为它是Python社区的主要焦点。
转载注明出处
原文(英文):effective python, item 1
译文(中文):
备注(提示):版权归原作者所有,如侵犯您的版权,请邮件联系我,我将会收到通知后,尽快删除!
阅读(...) 评论()

我要回帖

更多关于 输出python版本号 的文章

 

随机推荐