Skip to content

有沒有辦法直接回傳 timedelta datetime 或 arrow 的格式而非 dict? #7

Description

@r888800009

回傳 dict 沒辦法直接導入 timedelta 等時間類型,使用上不是很方便,比方說下面這種寫法也是沒辦法直接轉成 timedelta

timedelta(**{'day': 0, 'hour': 0, 'minute': 0, 'second': 5})

python 官方的定義是都加了 s,所以如果要轉換的話需要一個個對應

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)

至於判斷類別可以透過 isinstance() 比方說

isinstance(timedelta(), timedelta)

感覺這樣子使用上會比較方便?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions