How to get current time in python and break up into year, month, day, hour, minute?

后端 未结 11 1044
故里飘歌
故里飘歌 2020-11-28 01:18

I would like to get the current time in Python and assign them into variables like year, month, day, hour, minute

11条回答
  •  一生所求
    2020-11-28 02:22

    you can use datetime module to get current Date and Time in Python 2.7

    import datetime
    print datetime.datetime.now()
    

    Output :

    2015-05-06 14:44:14.369392
    

提交回复
热议问题