'内建模块的使用'

from datetime import datetime;# 注意datetime模块包含datetime类，如果只是import datetime则需要使用datetime.datetime

date = datetime.now();

print(date)


time = datetime(2019,7,26,10,37,45);
print(time)
val = time.timestamp();
print(val);

# timestemp准换成时间格式
dt = datetime.fromtimestamp(val);

print(dt)

# str 转datetime
dt1 = datetime.strptime("2017/7/26 22:16:43","%Y/%m/%d %H:%M:%S");

print(dt1) # 2017-07-26 22:16:43

# datetime 转str
str1  = dt1.strftime("%a , %b %d %H:%M")
print(str1)
