2

我正在尝试使用 Spyder (python 3.8) 删除 ftp 文件,但其中一个导入“ ftputil ”不起作用。错误代码看起来像

导入 ftputil ModuleNotFoundError:没有名为“ftputil”的模块

代码

 #! /usr/bin/python
 import time
 import ftputil
 host = ftputil.FTPHost('host', 'username', 'password')
 mypath = 'ftp_dir'
 now = time.time()
 host.chdir(mypath)
 names = host.listdir(host.curdir)
 for name in names:
   if host.path.getmtime(name) < (now - (3600)):
     if host.path.isfile(name):
        host.remove(name)
 host.close()

如果它不起作用,我们可以使用另一个导入。

4

1 回答 1

2

尝试使用以下说明安装它:

conda install -c conda-forge ftputil

有关更多信息,请查看此页面

于 2021-03-24T11:36:39.343 回答