#!/usr/bin/python import time,datetime from datetime import date file = '/Users/jian.wang13/code/test/0629shijian.txt' list = [] with open(file,'r',encoding='utf-8') as f: for i in f: tmp = i.strip() list.append(tmp) current_data = datetime.datetime.now().strftime('%Y-%m-%d') print(current_data) a,b,c = map(int,current_data.split('-')) print(a,b,c) num = date(a,b,c) yuan_dan = date(num.year+0,1,1) #jisuan = yuan_dan - num jisuan = num - yuan_dan jisuan1 = str(jisuan) jisuan1 = jisuan1.split(' ') jisuan2 = jisuan1[0] print(jisuan2) print(list) sum = 0 for i in list: sum += float(i) print((sum/float(jisuan2))*100)
時間文件
5
1.8
2.5