python得到电脑的开机时间方法
作者:Cosmop01itan 时间:2021-01-05 08:00:05
如下所示:
#先下载psutil库:pip install psutil
import psutil
import os,datetime
def main():
print "电脑的开机时间",
#调用psutil.boot_time()函数返回开机的时间戳
dt = datetime.datetime.fromtimestamp(psutil.boot_time())
#返回一个datetime对象
print dt.strftime("%Y-%m-%d,%H:%M:%S")
if __name__=="__main__":
main()
来源:https://blog.csdn.net/CosmopolitanMe/article/details/77885926
标签:python,开机,时间
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
django框架如何集成celery进行开发
2022-09-13 11:18:24
![](https://img.aspxhome.com/file/2023/4/67784_0s.png)
改善IE6中a与a:hover的背景支持
2009-11-27 18:50:00
Python-copy()与deepcopy()区别详解
2021-06-20 15:00:41
python目标检测给图画框,bbox画到图上并保存案例
2023-03-07 07:47:52
Python3.5 Pandas模块之Series用法实例分析
2022-07-23 16:19:09
![](https://img.aspxhome.com/file/2023/1/76181_0s.png)
PHP基于phpqrcode类库生成二维码过程解析
2023-11-17 19:06:35
白鸦:如何设计用户体验?
2008-01-03 16:53:00
高效交换XML文档
2008-01-03 14:16:00
PHP高级编程实例:编写守护进程
2023-10-27 02:03:22
Python pandas如何向excel添加数据
2021-07-14 17:37:41
利用ASP远程注册DLL的方法
2008-03-05 13:00:00
图像检索之基于vlfeat实现SIFT特征
2021-11-18 13:13:40
![](https://img.aspxhome.com/file/2023/0/91950_0s.png)
使用SQL Server时最容易忽略的21个问题
2009-01-13 13:59:00
类型转换的小乐趣
2010-11-30 21:37:00
Python 自动化表单提交实例代码
2022-12-20 06:16:14
![](https://img.aspxhome.com/file/2023/5/77825_0s.png)
python中实现php的var_dump函数功能
2023-11-16 07:11:04
![](https://img.aspxhome.com/file/2023/2/101712_0s.jpg)
php flv视频时间获取函数
2023-09-04 13:41:48
为什么不压缩 HTML
2010-05-07 12:37:00
实现页面中按钮刷新的N种方法
2007-02-03 11:06:00
python多进程 主进程和子进程间共享和不共享全局变量实例
2022-11-05 11:42:56
![](https://img.aspxhome.com/file/2023/1/85261_0s.jpg)