【问题标题】:PythonAnywhere Script Scheduler Not WorkingPythonAnywhere 脚本调度程序不工作
【发布时间】:2017-01-25 17:25:15
【问题描述】:

当我转到文件并点击运行时,我有一个运行良好的 python 脚本。但是,当调度程序运行它时,脚本会失败。这可能是什么原因造成的?

这是我的脚本:

import time
import os
import shutil
import stat

for i in os.listdir():
    if os.path.isdir(i):
         shutil.rmtree(i)

这是我在调度程序运行时遇到的错误

Traceback (most recent call last):
  File "filepath/myscript.py", line 7, in <module>
    for i in os.listidir():
TypeError: listdir() takes exactly 1 argument (0 given)

2017-01-25 17:10:12 -- Completed task, took 0.00 seconds, return code was 1.

我很困惑为什么当我手动运行它时它会起作用,但在计划运行它时却不起作用。

【问题讨论】:

标签: python scheduler pythonanywhere


【解决方案1】:

您在 2 个不同的 Python 版本下运行它。 Python 2 需要路径,但 Python 3 是可选的,默认为 '.'。

【讨论】:

    猜你喜欢
    • 2012-06-12
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-08
    • 2021-12-04
    • 2023-03-09
    相关资源
    最近更新 更多