How to specify date and time in python?

后端 未结 4 1071
自闭症患者
自闭症患者 2021-02-06 23:12

Quite simple newbie question:

What is the object used in python to specify date (and time) in Python?

For instance, to create an object that holds a given date a

4条回答
  •  一整个雨季
    2021-02-06 23:30

    Simple example:

    >>> import datetime
    # 05/10/09 18:00
    >>> d = datetime.datetime(2009, 10, 5, 18, 00)
    >>> print d.year, d.month, d.day, d.hour, d.second
    2009 10 5 18 0
    >>> print d.isoformat(' ')
    2009-10-05 18:00:00
    >>> 
    

提交回复
热议问题