def fmt_time_1():
a = datetime.datetime.now(tz=None)
print('方法里面:',a)
str_time = a.strftime("%Y-%m-%d, %H:%M:%S, %w")
print(str_time)
a = datetime.datetime.now(tz=None)
print('直接输出',a)
print('直接输出',a.strftime("%Y-%m-%d, %H:%M:%S, %w"))
print('直接输出',a.timestamp())
print('直接输出',datetime.datetime.fromtimestamp(time.time()))
print('直接输出',a.timetuple())
def fmt_time_2():
a = datetime.datetime.utcnow()
print('方法里面:',a)
b = datetime.datetime.utcnow()
print('直接输出',b)
print('直接输出',b.strftime("%Y-%m-%d, %H:%M:%S, %w"))
print('直接输出',b.timestamp())
print('直接输出',datetime.datetime.utcfromtimestamp(time.time()))
print('直接输出',b.timetuple())
a_datetime = datetime.datetime.strptime("2016-11-15, 15:32:12, 2", "%Y-%m-%d, %H:%M:%S, %w")
print('直接输出',a_datetime)
if __name__=="__main_":
fmt_time_1()
fmt_time_2()