获取通过 pip 安装的软件包的安装日期和时间

2022-01-13 00:00:00 python pip package

问题描述

我想找到一种方法来获取我通过 pip 安装的包的小时:分钟:秒格式的日历日期和时间.

I would like to find a way to get the calendar date and time in hour:minute:seconds format for my packages installed via pip.

我希望能够在输出中看到如下内容:月/日/年 - 时:分:秒对于每个包.

I would like to be able to see something in output like: Month/Day/Year - Hour:Minute:Seconds for each package.

谢谢!


解决方案

这是你要找的 -

import pip
import os
import time

In [139]: for package in pip.get_installed_distributions():
   .....:          print "%s: %s" % (package, time.ctime(os.path.getctime(package.location)))
   .....:     
pyudev 0.17.dev20150317: Tue Mar 17 12:02:58 2015
python-magic 0.4.6: Fri Mar 20 14:07:59 2015
runipy 0.1.0: Fri Oct 31 01:49:34 2014

代码来源 - https://stackoverflow.com/a/24736563/170005

import pip 也可以,非常有趣.我不知道这个.

You can do import pip too, which is pretty interesting. I didn't know this.

相关文章