Commit 876508a0 authored by 高雅喆's avatar 高雅喆

change get_yesterday_format

parent aa2c9ea1
...@@ -116,7 +116,7 @@ print("done") ...@@ -116,7 +116,7 @@ print("done")
def result2file(): def result2file():
output_path = DIRECTORY_PATH + "result_{}.txt".format(get_yesterday_date()) output_path = DIRECTORY_PATH + "result_{}.txt".format(get_yesterday_date().replace('-',''))
with open(output_path, 'w') as f: with open(output_path, 'w') as f:
tplt = "{0:\u3000<6}\t{1:\u3000<15}\t{2:\u3000<15}\t{3:\u3000<15}\n" tplt = "{0:\u3000<6}\t{1:\u3000<15}\t{2:\u3000<15}\t{3:\u3000<15}\n"
line = """数据日期:{} line = """数据日期:{}
...@@ -141,7 +141,7 @@ def result2file(): ...@@ -141,7 +141,7 @@ def result2file():
具体内容:以下所有数据都是昨天一天的首页的 具体内容:以下所有数据都是昨天一天的首页的
""".format(get_yesterday_date()) """.format(get_yesterday_date().replace('-',''))
f.write(line) f.write(line)
f.write("#1. 比例特征\n") f.write("#1. 比例特征\n")
f.write("=================================================================\n") f.write("=================================================================\n")
...@@ -265,7 +265,7 @@ def result2file(): ...@@ -265,7 +265,7 @@ def result2file():
def rate2file(): def rate2file():
output_path = DIRECTORY_PATH + "rate.csv" output_path = DIRECTORY_PATH + "rate.csv"
with open(output_path, 'a+') as f: with open(output_path, 'a+') as f:
line = get_yesterday_date()+','+\ line = get_yesterday_date().replace('-','')+','+\
str(answer_imp_rate_all[3])+','+str(answer_imp_rate_ios[3])+','+str(answer_imp_rate_android[3])+','+\ str(answer_imp_rate_all[3])+','+str(answer_imp_rate_ios[3])+','+str(answer_imp_rate_android[3])+','+\
str(diary_imp_rate_all[3])+','+str(diary_imp_rate_ios[3])+','+str(diary_imp_rate_android[3])+','+\ str(diary_imp_rate_all[3])+','+str(diary_imp_rate_ios[3])+','+str(diary_imp_rate_android[3])+','+\
str(activate_uid_ctr_all[3])+','+str(activate_uid_ctr_ios[3])+','+str(activate_uid_ctr_android[3])+','+\ str(activate_uid_ctr_all[3])+','+str(activate_uid_ctr_ios[3])+','+str(activate_uid_ctr_android[3])+','+\
......
...@@ -124,7 +124,7 @@ def main(): ...@@ -124,7 +124,7 @@ def main():
clk_diary_ctr_android = top_diary_android.get_result("安卓", 4, "ctr") clk_diary_ctr_android = top_diary_android.get_result("安卓", 4, "ctr")
result_lst = [clk_diary_ctr_all, clk_diary_ctr_ios, clk_diary_ctr_android] result_lst = [clk_diary_ctr_all, clk_diary_ctr_ios, clk_diary_ctr_android]
output_path = DIRECTORY_PATH + "top100_ctr_diary_{}.txt".format(get_yesterday_date()) output_path = DIRECTORY_PATH + "top100_ctr_diary_{}.txt".format(get_yesterday_date().replace('-',''))
top_diary_all.result2file(result_lst, output_path) top_diary_all.result2file(result_lst, output_path)
print("已获取 Top diary 特征") print("已获取 Top diary 特征")
...@@ -139,7 +139,7 @@ def main(): ...@@ -139,7 +139,7 @@ def main():
clk_answer_ctr_android = top_answer_android.get_result("安卓", 2, "ctr") clk_answer_ctr_android = top_answer_android.get_result("安卓", 2, "ctr")
result_lst = [clk_answer_ctr_all, clk_answer_ctr_ios, clk_answer_ctr_android] result_lst = [clk_answer_ctr_all, clk_answer_ctr_ios, clk_answer_ctr_android]
output_path = DIRECTORY_PATH + "top100_ctr_answer_{}.txt".format(get_yesterday_date()) output_path = DIRECTORY_PATH + "top100_ctr_answer_{}.txt".format(get_yesterday_date().replace('-',''))
top_answer_all.result2file(result_lst, output_path) top_answer_all.result2file(result_lst, output_path)
print("已获取 Top answer 特征") print("已获取 Top answer 特征")
......
...@@ -27,11 +27,11 @@ def tuple2dict(tuple_result): ...@@ -27,11 +27,11 @@ def tuple2dict(tuple_result):
return dict_result return dict_result
def get_yesterday_date(): def get_yesterday_date():
#自动获取昨天的日期,如"20180808" #自动获取昨天的日期,如"2018-08-08"
""" """
:rtype : str :rtype : str
""" """
today = datetime.date.today() today = datetime.date.today()
yesterday = today - datetime.timedelta(days=1) yesterday = today - datetime.timedelta(days=1)
yesterday = yesterday.strftime("%Y%m%d") yesterday = yesterday.strftime("%Y-%m-%d")
return yesterday return yesterday
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment