#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:albert time:2019/1/21
import time
import datetime
import calendar
now = datetime.datetime.now()
print(now)
print(type(now))
tick = time.time()
print(tick)
localtime = time.localtime(tick)
print(localtime)
cur_time = time.asctime(localtime)
print(cur_time)
format_time = time.strftime('%Y-%m-%d %H:%M:%S %p %A %B %c',localtime)
print(format_time)
new_now = datetime.datetime.now().strftime('%Y%m%d %H:%M:%S')
print(new_now)
print(type(new_now))
new_now = datetime.datetime.strptime(new_now,'%Y%m%d %H:%M:%S')
print(new_now)
print(type(new_now))
date = datetime.datetime.now().date()
print(date)
print(type(date))
today = datetime.date.today()
print(today)
tomarrow = today + datetime.timedelta(days=1)
print(tomarrow)
thired_days_ago = today + datetime.timedelta(days=-3)
print(thired_days_ago)
week = today.weekday()
print(week)
【python内置】03learn_time
最新推荐文章于 2022-04-19 11:44:06 发布