How to get the current time in Python

前端 未结 30 2046
滥情空心
滥情空心 2020-11-22 06:47

What is the module/method used to get the current time?

30条回答
  •  感动是毒
    2020-11-22 07:20

    if you are using numpy already then directly you can use numpy.datetime64() function.

    import numpy as np
    str(np.datetime64('now'))
    

    for only date:

    str(np.datetime64('today'))
    

    or, if you are using pandas already then you can use pandas.to_datetime() function

    import pandas as pd
    str(pd.to_datetime('now'))
    

    or,

    str(pd.to_datetime('today'))
    

提交回复
热议问题