It is a renewed alternative implementation for Python's original platform.linux_distribution function, but it also provides much more functionality which isn't necessarily Python bound like a command-line interface
The stdlib is not the right place for things that change this often. Just look at how many semi standards we've seen in the last few years. There's no point in trying to follow these in a slow moving code base as the Python stdlib. It's much better to put the functionality into a PyPI module which can be updated much more frequently.
$ pip3 install user distro
$ python3
Python 3.6.3 (default, Oct 9 2017, 12:07:10)
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distro
>>> distro.linux_distribution()
('Fedora', '27', 'Twenty Seven')
The platform.dist() and platform.linux_distribution() functions are now deprecated. Linux distributions use too many different ways of describing themselves, so the functionality is left to a package. (Contributed by Vajrasky Kok and Berker Peksag in bpo-1322.)
您可以使用^{} project :
这个项目来自issue #1322,这导致了函数的弃用。从project README:
该方法已从
platform
库中删除,因为用于检测您所使用的发行版的正确方法的更改速度快于Python发布计划。从上面的错误报告:根据Jim的回答,这个功能将从Python中删除。distro包似乎是推荐的替代方案:
那就剩下一个包裹了。来自此更改的新增内容:
您可以查看删除它的issue 1322以进行更详细的讨论,还有a package there already。在
由于Python标准库会带来维护开销,因此您无法在Python标准库中执行此操作。在
相关问题 更多 >
编程相关推荐