擅长:python、mysql、java
<p>要按计划运行命令,可以使用无限<code>while</code>循环和<code>time.sleep</code>,这需要几秒钟的时间来延迟线程执行,方法是:</p>
<pre><code>import time
import os
while True:
os.system("ipconfig /flushdns")
time.sleep(3600)
</code></pre>
<p>如果您正在这个程序中执行其他操作,您可能希望在<a href="https://docs.python.org/3/library/threading.html" rel="nofollow noreferrer">thread</a>中运行这个循环</p>
<p>要将程序“编译”成Windows可执行文件,可以使用<a href="https://www.py2exe.org/" rel="nofollow noreferrer">py2exe</a>或<a href="https://cx-freeze.readthedocs.io/en/latest/" rel="nofollow noreferrer">cx_Freeze</a>(仅举一些例子,肯定有更多的工具具有此功能)</p>