为了后期编写日志时,统一打印时间格式代码如下:
#coding=utf-8
import time
class GetTime(object):
def get_system_time(self):
print(time.time()) #显示当前时间
print(time.localtime()) #显示当前时间
new_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())#格式转换
print(new_time)
gettime=GetTime()
gettime.get_system_time()
运行结果: