【问题标题】:Repetitive execution of a Python code daily without Javascript在没有 Javascript 的情况下每天重复执行 Python 代码
【发布时间】:2022-01-29 20:47:51
【问题描述】:

我打算使用 Python 生成将保存到外部文件的 HTML 代码。 HTML 代码将显示当天。不允许使用 Javascript 和 PHP。如何让 Python 代码在午夜后每天重复,以便相应的 HTML 文件包含一周中的有效日期信息?谢谢你。我的代码:

import datetime
t=datetime.datetime.now()

s="""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Daily Portal</title>
</head>
<body>

<div>{maininfo:}</div>
 
</body>
</html>"""


s1=t.strftime("%A")
s2="Good morning John. Today is "+s1+"."+" Have a beautiful day."

s=s.format(maininfo=s2)

print(s)

【问题讨论】:

    标签: python html


    【解决方案1】:

    您可以设置一个作业调度程序来每天执行代码。请参考 herehere(如果您在 unix 系统上运行)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-17
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多