0
다운로드가 파이썬에서 작동하지 않습니까?python 스크립트를 사용하여 FTP 위치에서 디렉토리/파일을 다운로드하십시오.
FTP 위치에서 파일을 가져 오기 위해 간단한 파이썬 프로그램을 작성했지만 실행하면 [Errno 13] Permission denied 메시지가 표시됩니다.
내 코드는 다음과 같습니다. 왜 그것이 작동하지 않는지 아는가?
import ftplib
from ftplib import FTP, error_perm
def getFTPDir(dirpath):
f = ftplib.FTP(ip, username, password)
try:
f.cwd(dirpath)
nameList = f.nlst()
oldest = nameList[0]
newest = nameList[-1]
newest = oldest
newDirPath = dirpath +'/'+ newest
print f.cwd(newDirPath)
subNameList = f.nlst()
for i in range (len(subNameList)):
f.cwd(newDirPath + '/' + str(subNameList[i]))
nameList1 = f.nlst()
filename = nameList1[i]
print "downloading..............", filename
f.retrbinary('RETR '+ filename, open(os.path.join(destination,localPath),"wb").write)
print filename + " downloaded"
try:
fhandle = open(filename, 'wb')
f.retrbinary('RETR ' + filename, fhandle.write)
except Exception, e:
print str(e)
finally:
fhandle.close()
except error_perm:
return
except Exception, e:
print str(e)
finally:
f.close()
오류가 발생 줄 무엇을 말 해주세요 ... 당신이 작성하려고 곳
그런 식으로, 당신이 볼 수 : UT는 다음 줄에 쓴 일을 계속, 또는 더 나은 함께 사용 ... –
f.retrbinary ('RETR'+ 파일 이름, 열려있는 (os.path.join (대상, 로컬 경로), "wb" – Dush