python 中格式化时间

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import time

if __name__ =='__main__':

#localtime = time.localtime(time.time())
#print(localtime)
#print('\n')
str_time = time.strftime("%Y_%m_%d_%H_%M_%S",time.localtime())
print(str_time)

 

 

运行结果

 

 

posted on 2021-07-13 18:41  让代码改变世界ha  阅读(81)  评论(0编辑  收藏  举报

导航