如何在python数据类中定义日期时间字段?

前端之家收集整理的这篇文章主要介绍了如何在python数据类中定义日期时间字段?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

试图获得Python 3.7新数据类的语法.

如果我想在我的数据类中包含日期时间值,

@H_404_7@import datetime from dataclasses import dataclass @dataclass class MyExampleWithDateTime: mystring: str myint: int mydatetime: ???

我该怎么写???对于日期时间字段?

最佳答案
像这样:

@H_404_7@@dataclass class MyExampleWithDateTime: mystring: str myint: int mydatetime: datetime.datetime

猜你在找的Python相关文章