cpanel web上ftp上载文件出现“模块对象不可调用”错误

2024-10-02 18:22:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过python将文件发送到cpanlweb服务器,第一次我创建了一个ftp用户,然后我使用这个代码进行上传,但是出现了以下错误

python代码:

import ftplib as FTP

ftp = FTP("ftp.example.com")
ftp.login (username='xxxxxxxxxxxxxxx', password="xxxxxxxx")
ftp.cwd('/home/example/public_html/img')

def image_ftp_send():

    filename = '1.jpg'
    ftp.storbinary('STOR '+filename , open(file, 'rb'))
    ftp.quit()  

错误:

Traceback (most recent call last):
  File "Image ftp", line 24, in <module>
    ftp = FTP("ftp.example.com")
TypeError: 'module' object is not callabl

Tags: 文件代码用户import服务器comexampleas
1条回答
网友
1楼 · 发布于 2024-10-02 18:22:11

下面的代码没有您得到的错误。你知道吗

import ftplib 
ftp = ftplib.FTP('ftp.example.com')
ftp.login (username='xxxxxxxxxxxxxxx', password="xxxxxxxx")
ftp.cwd('/home/example/public_html/img')

相关问题 更多 >