没有!没有可用的功能,该功能使您可以基于事件ID获取事件。
参考:事件记录功能
GetNumberOfEventLogRecords Retrieves the number of records in the specified event log.GetOldestEventLogRecord Retrieves the absolute record number of the oldest record in the specified event log.NotifyChangeEventLog Enables an application to receive notification when an event is written to the specified event log.ReadEventLog Reads a whole number of entries from the specified event log.RegisterEventSource Retrieves a registered handle to the specified event log.
唯一感兴趣的其他方法是读取最早的事件。
您将必须以任何方式遍历结果,并且您的方法正确:)
您只能像下面那样更改方法的形式,但这是不必要的。
events = win32evtlog.ReadEventLog(hand, flags,0)events_list = [event for event in events if event.EventID == "27035"]if event_list: print 'Event Category:', events_list[0].EventCategory
这和您做的一样,但更简洁



