通過FTP發送的文件我曾嘗試下面的代碼,並改變了所有可能的方式像無法使用Python 2.6
storbinary到storlines和[R到RB和RB +但即使沒有運氣將文件傳輸到服務器。下面是我的示例代碼:
from ftplib import FTP
ftpfile = FTP('hostname')
print "Connected with server"
ftpfile.cwd('path of server where file need to store')
print "Reached to target directory"
myFile = open(inputfile, 'rb+')
ftpfile.storbinary('STOR ' +inputfile, myFile)
print "transferring file..."
myFile.close()
print "file closed"
ftpfile.quit()
print "File transferred"
的代碼只是運行和輸出的所有打印語句,但是當我在服務器檢查有沒有文件created.Consider登錄成功完成。
需要建議以實現所需的輸出。謝謝
您應該檢查的'storebinary' – mata
到底是什麼'inputfile'反應? –
@BurhanKhalid輸入文件是我本地系統中的文本文件。例如inputfile ='c:\ working \ cyborg.txt' – cyborg