python3+selenium(十九)格式化显示系统时间

为了后期编写日志时,统一打印时间格式代码如下:

#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()

运行结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Amy8020/article/details/88971833
今日推荐