2020
10-28
10-28
基于python获取本地时间并转换时间戳和日期格式
附上代码与运行结果截图:importtime#获取当前时间now=time.localtime()#格式化日期now_=time.strftime('%Y-%m-%d%H:%M:%S',now)#获取当前时间,以时间戳格式now_stamp=time.time()#日期转时间戳change_to_stamp=time.mktime(time.strptime(now_,"%Y-%m-%d%H:%M:%S"))#时间戳转日期change_to_time=time.strftime("%Y-%m-%d%H:%M:%S",time.localtime(now_stamp))print(now)print(now_)print(now_stamp)print(...
继续阅读 >