如何检查PyWin时间类型

2024-06-16 09:39:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图检查PyWin在带有Excel的COM接口中返回的数据是否属于“time”类型。在

以下是不起作用的代码:

from win32com.client import Dispatch
from pywintypes import Time
cellToTest = Dispatch('Excel.Application').Sheets('SomeSheet').Range('SomeCell').Value
if type( cellToTest ) == Time:
    print 'It\'s an excel time type'

因为这:type(Time)

返回这个:<type 'builtin_function_or_method'>

但是这个:type(cellToTest)

返回这个:<type 'time'>


Tags: 数据代码fromimportcomclient类型time