0
試圖與jinja2保存html報告。有我的代碼:保存與模板jinja2的html報告
from jinja2 import FileSystemLoader, Environment, Template
templateEnv = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__),'templates')))
template = templateEnv.get_template("report_temp.html")
user = 'dear user'
outputText = template.render(user = user,
sampleCount = sampleCount,
finishCount = finishCount,
inside4Count = inside4Count,
inside10Count = inside10Count,
finish_rate = finish_rate,
inside4_rate = inside4_rate,
inside10_rate = inside10_rate,
sectionResults = sectionResults,
error = getError(results))
# print(outputText)
with open("report_temp.html", "w") as f:
f.write(outputText)
沒有錯誤,但沒有任何反應:沒有文件,什麼原因可能是?以及如何使文件名稱日期:創建時間?