There are several modules in Python to express the time.

Module time

Time access and conversions.

Module datetime

More object-oriented interface to dates and times. Provides the time and datetime types with which the ZoneInfo class is designed to be used.

Module zoneinfo

The zoneinfo module provides a concrete time zone implementation to support the IANA time zone database.

from zoneinfo import ZoneInfo
import datetime 

dt = datetime.datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))

Module calendar

General calendar-related functions. timegm() is the inverse of gmtime() from this module.

Package dateutil

Third-party library dateutil provides powerful extensions to datetime module with expanded time zone and parsing support.

Module locale

Internationalization services. The locale setting affects the interpretation of many format specifiers in strftime() and strptime.

本文系Spark & Shine原创,转载需注明出处本文最近一次修改时间 2022-03-17 21:00

results matching ""

    No results matching ""