Is there a way to decode numerical COM error-codes in pywin32

前端 未结 5 1076
别那么骄傲
别那么骄傲 2020-12-28 15:26

Here is part of a stack-trace from a recent run of an unreliable application written in Python which controls another application written in Excel:

pywintype         


        
5条回答
  •  心在旅途
    2020-12-28 16:05

    Do it like this:

    try:
        [whatever code]
    except pythoncom.com_error as error:
        print(win32api.FormatMessage(error.excepinfo[5]))
    

    More information on digesting the pythoncom.com_error object here: http://docs.activestate.com/activepython/3.2/pywin32/com_error.html

提交回复
热议问题