获取Python软件包版本

Part of maintaining a Django-based application like MDN's kuma is ensuring Python packages are up to date.  I was recently testing an upgrade on a remote system and needed to ensure that a given Python package was at the version number it should be.  Here's how I retrieved the package version:

维护MDN的kuma之类的基于Django的应用程序的一部分是确保Python软件包是最新的。 我最近正在远程系统上测试升级,因此需要确保给定的Python软件包的版本号应为该版本号。 这是我检索软件包版本的方法:


import nose   # Nose is a test utility.  Replace with your desired package here.
nose.__version__

# Output:  0.3.1


The __version__ property returns the exact version number for a Python package.  Some Python packages use a VERSION property as well, but __version__ should be the most reliable.

__version__属性返回Python软件包的确切版本号。 一些Python包也使用VERSION属性,但是__version__应该是最可靠的。

翻译自: https://davidwalsh.name/python-package-version

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值