datetime妯″潡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了datetime妯″潡相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/style' title='style'>style
mes rom time() code pre port cond mtimedatetime妯″潡
# datetime妯″潡鍙互鐪嬫垚鏄椂闂村姞鍑忕殑妯″潡 import datetime # 杩斿洖褰撳墠鏃堕棿 print(datetime.datetime.now()) 2019-03-07 16:22:14.544130 print(datetime.date.fromtimestamp(time.time())) 2019-03-07 # 褰撳墠鏃堕棿+3澶?/span> print(datetime.datetime.now() + datetime.timedelta(3)) 2019-03-10 16:22:14.560599 # 褰撳墠鏃堕棿-3澶?/span> print(datetime.datetime.now() + datetime.timedelta(-3)) 2019-03-04 16:22:14.568473 # 褰撳墠鏃堕棿-3灏忔椂 print(datetime.datetime.now() + datetime.timedelta(hours=3)) 2019-03-07 19:22:14.575881 # 褰撳墠鏃堕棿+30鍒嗛挓 print(datetime.datetime.now() + datetime.timedelta(minutes=30)) 2019-03-07 16:52:14.585432 # 鏃堕棿鏇挎崲 c_time = datetime.datetime.now() print(c_time.replace(minute=20, hour=5, second=13)) 2019-03-07 05:20:13.595493
以上是关于datetime妯″潡的主要内容,如果未能解决你的问题,请参考以下文章