试图与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)
没有错误,但没有任何反应:没有文件,什么原因可能是?以及如何使文件名称日期:创建时间?