首页 > 解决方案 > Python如何转换WMI日期格式

问题描述

我正在使用下面的 python 代码来获取进程创建时间。但时间格式是 WMI 日期时间格式,即 20050718095318.019149-420 我想将其转换为可读格式

import wmi
from datetime import datetime
from dateutil import parser

# Initializing the wmi constructor
f = wmi.WMI()

# Printing the header for the later columns
print("pid Process name")

# Iterating through all the running processes
#for process in f.Win32_Process():
    
    # Displaying the P_ID and P_Name of the process
    #print(f"{process.ProcessId:<10} {process.Name} {PrivatePageCount}")
for process in f.Win32_Process (name="notepad.exe"):
    print (process.ProcessId, process.Name,process.CreationDate)

标签: pythonwmidatetime-format

解决方案


推荐阅读