组保留的标签 余下为需要删除的标签 unset($oldtag[$key]); } } } if (!empty($oldtag)) { $tagids = array(); foreach ($oldtag as $tagid => $tagname) { $tagids[] = $tagid; } well_oldtag_delete($tagids, $tid); } $r = well_tag_process($tid, $fid, $create_tag, $tagarr); return $r; } // 删除标签和绑定的主题 function well_oldtag_delete($tagids, $tid) { $pagesize = count($tagids); $arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize); $delete_tagids = array(); // 删除 $tagids = array(); $n = 0; foreach ($arrlist as $val) { ++$n; if (1 == $val['count']) { // 只有一个主题 $delete_tagids[] = $val['tagid']; } else { $tagids[] = $val['tagid']; } } !empty($delete_tagids) and well_tag_delete($delete_tagids); $arlist = well_tag_thread_find_by_tid($tid, 1, $n); if ($arlist) { $ids = array(); foreach ($arlist as $val) $ids[] = $val['id']; well_tag_thread_delete($ids); } !empty($tagids) and well_tag_update($tagids, array('count-' => 1)); } // 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签 function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array()) { if (empty($tid)) return ''; // 新标签处理入库 if ($new_tags) { $threadarr = array(); $tagids = array(); $i = 0; $size = 5; $n = count($tagarr); $n = $n > $size ? $size : $size - $n; foreach ($new_tags as $name) { ++$i; $name = trim($name); $name = stripslashes($name); $name = strip_tags($name); $name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name); $name = htmlspecialchars($name, ENT_QUOTES); if ($name && $i <= $n) { // 查询标签 $read = well_tag_read_name($name); if ($read) { // 存在 count+1 $tagids[] = $read['tagid']; } else { // 入库 $arr = array('name' => $name, 'count' => 1); $tagid = well_tag_create($arr); FALSE === $tagid and message(-1, lang('create_failed')); $read = array('tagid' => $tagid, 'name' => $name); } $tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid); $threadarr[] = $tag_thread; $tagarr[$read['tagid']] = $read['name']; } } !empty($threadarr) and tag_thread_big_insert($threadarr); !empty($tagids) and well_tag_update($tagids, array('count+' => 1)); } $json = empty($tagarr) ? '' : xn_json_encode($tagarr); return $json; } ?>Windows 系统如何定时运行 Python 程序或脚本|江阴雨辰互联

Windows 系统如何定时运行 Python 程序或脚本

需求 我们经常有需要在系统上定时运行某个 Python 脚本来执行任务&#xff0c;例如每天定时运行 Python 爬虫脚本来获取数据&#xff0c;那在 Windows 系统上该如何定时运行 Python 脚本或程序呢

需求

我们经常有需要在系统上定时运行某个 Python 脚本来执行任务,例如每天定时运行 Python 爬虫脚本来获取数据,那在 Windows 系统上该如何定时运行 Python 脚本或程序呢?

步骤

1.快捷键 Win + x 打开计算机管理界面:

2.点击任务计划程序,选择创建基本任务:

3.设置任务名称,描述可写可不写,点击下一步:

4.设置任务执行的频率,点击下一步:

5.设置任务执行的时间和间隔,点击下一步:

6.操作选择启动程序,点击下一步:

7.设置脚本或程序的位置,点击下一步:

  • 定时运行 Python 脚本
    程序或脚本选择 Python 解释器的位置,添加参数为 Python 脚本,起始于脚本所在目录(test.py 的功能为输出一行 ‘Hello World!’):

  • 定时运行 Python 打包生成的 .exe 可执行文件
    使用 pyinstaller 打包 Python 脚本:pyinstaller -F test.py
    生成 test.exe 文件后,将程序或脚本选择该可执行文件即可,添加参数可为空,起始于 .exe 文件所在目录:

8.点击完成:

结果

1.点击刷新可以看到刚刚设置的任务:

2.双击打开可选择立即运行或者等到设定的时间,Python 程序或脚本会被自动执行:

启用所有任务历史记录可开启查看任务运行日志,点击属性可对该任务进行修改

发布者:admin,转转请注明出处:http://www.yc00.com/web/1734738765a3750460.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信