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)
运行结果