PythonAnywhere 脚本调度程序不工作

PythonAnywhere Script Scheduler Not Working

我有一个 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.

我很困惑为什么这在我手动 运行 时有效,但在计划 运行 时却无效。

你 运行 它有 2 个不同的 Python 版本。 Python 2 需要路径,但 Python 3,它是可选的,默认为“.”。