简体   繁体   English

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

[英]How do I define a datetime field in a python dataclass?

trying to get the syntax of the Python 3.7 new dataclass right. 试图获得Python 3.7新数据类的语法。

if I want to include a datetime value in my dataclass, 如果我想在我的数据类中包含日期时间值,

import datetime
from dataclasses import dataclass

@dataclass
class MyExampleWithDateTime:
    mystring: str
    myint: int
    mydatetime: ???

What should I write for ??? 我该怎么写??? for a datetime field? 对于日期时间字段?

Like this: 像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM