我有一点python
代码来上传一些gifs
到FTP服务器。当我的脚本在我的gif dir
中时,当我使用img = "name.gif"
之类的东西时,代码工作得很好。在
但只要我想使用下面这样的绝对路径:
img = "/home/pi/photobooth/gif/name.gif"
我收到一个550错误提示我/home/pi/photobooth/gif/name.gif: no such file or directory
有人知道为什么吗?
我的代码如下:
from ftplib import FTP
import sys
def ULimg(img):
host = 'host.com'
user = 'user'
passwd = 'pass'
try:
ftp = FTP(host)
ftp.set_pasv(False)
ftp.login(user, passwd)
except:
print('Error connecting to FTP server')
sys.exit()
file = open(img, 'rb')
ftp.storbinary('STOR ' + img, file)
file.close()
ftp.quit()
img = '/home/pi/photobooth/gif/name.gif'
ULimg(img)
下面是我使用绝对路径时得到的error
:
回溯(最近一次呼叫):
^{pr2}$如果有人能帮忙,谢谢!
目前没有回答
相关问题 更多 >
编程相关推荐