python - 为什么我无法在代码中确定对象是 DateTime 类型?

标签 python ironpython spotfire

我有一个变量 v,当我这样做时

print type(v)

我明白了

<type 'DateTime'>

但是当我这样做的时候

if type(v) in (datetime, datetime.date, datetime.datetime, datetime.time):

这不是真的

问题是:为什么?

编辑:

DateTime 类型是 Spotfire 特定类型。

https://docs.tibco.com/pub/doc_remote/spotfire/7.9.0/TIB_sfire-analyst_7.9.0_api/html/F_Spotfire_Dxp_Data_DataType_DateTime.htm

最佳答案

我测试了它,这个条件是True

import datetime


v = datetime.datetime.now()  # maybe your problem is here.
print(type(v))

if type(v) in (datetime, datetime.date, datetime.datetime, datetime.time):
    print("I'm True")

else:
    print("I'm False")

输出:

<type 'datetime.datetime'>
"I'm True"

关于python - 为什么我无法在代码中确定对象是 DateTime 类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50413051/

相关文章:

ironpython - Spotfire:带 Action 控制的日期过滤

c# - "Access to the path ' D :\\Windows\\system32\\file is denied"Azure Web App

R - 检查字符串是否包含特定日期范围内的日期

python - Scrapy:连接被拒绝

python - help() 与 unicode __author__ 字符串

ironpython - 将IronPython嵌入WinForms应用程序中并中断执行

Python - 迭代任何类型的列表结构

url-redirection - 单击链接后 Spotfire 重定向到主页

python - python中的模块级垃圾收集

python - 返回字段值为 1 或 3 的文档