unix 时间戳转 时间

import time
a = 1381419600
print(a)
b = time.localtime(a)
print (b)
c
= time.strftime("%Y-%m-%d %H:%M:%S", b)
print (c)



#执行结果
1381419600  #unix时间戳

  time.struct_time(tm_year=2013, tm_mon=10, tm_mday=10, tm_hour=23, tm_min=40, tm_sec=0, tm_wday=3, tm_yday=283, tm_isdst=0)

  2013-10-10 23:40:00 #需要的时间格式

 

 

////////////////////////////////////////////////////////////////////

 

 

import time
s = []
with open('time.txt', 'r') as f:
for yy in f.readlines():
line = yy.strip().split()
s.append(line[0])
for a in s:
print(time.strftime("%Y.%m.%d %H:%M:%S", time.localtime(int(a))))

 

 

 

/// time.txt 内容如下 ////////////////////////////////////////

1535621738
1535622243
1535622314
1535622404
1535623092
1535623094
1535624287
1535624320
1535624944
1535625301
1535625850
1535626043
1535626065
1535626171
1535627142
1535628081
1535628623
1535629043
1535629383
1535630370
1535630474
1535630764
1535631174
1535631352
1535632063
1535632197
1535632308
1535632347
1535633404
1535633486
1535633594
1535633889
1535634054
1535634216
1535634594
1535634790
1535634878
1535635361
1535635361
1535635382
1535635551
1535635770
1535636795
1535637097
1535637100
1535637337
1535637380
1535637701
1535637990
1535638429
1535638460
1535638709
1535638927
1535639173
1535639452
1535639718
1535639740
1535639764
1535639912
1535640060
1535640152
1535640194
1535641140
1535641516
1535641891
1535641892
1535641892
1535642030
1535642107
1535642294
1535642651
1535643088
1535643306
1535644866
1535645015
1535645191
1535645716
1535646174
1535646176
1535646459
1535647450
1535647610
1535648355
1535648491
1535649375
1535649532
1535650103
1535650231
1535650566
1535651887
1535652871
1535658748
1535658833
1535661966
1535663811
1535666129
1535666288
1535671930
1535672608
1535673587
1535674288
1535674566
1535674788
1535676779
1535677335
1535678061
1535678283
1535678541
1535678549
1535678864
1535679059
1535679836
1535681055

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted on 2018-08-31 13:24  蓝码骑士  阅读(109)  评论(0)    收藏  举报

导航