Created
December 15, 2011 12:31
-
-
Save dketov/1480939 to your computer and use it in GitHub Desktop.
Протокол FTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Получение списка файлов | |
""" | |
from ftplib import FTP | |
ftp = FTP('ftp.cwi.nl') # connect to host, default port | |
ftp.login() # user anonymous, passwd anonymous@ | |
ftp.retrlines('LIST') # list directory contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Получение файла с сервера | |
""" | |
ftp = ftplib.FTP('127.0.0.1', 'book', 'bookpw') | |
f = open("MyPycFile.pyc", "wb") | |
ftp.set_pasv(1) | |
ftp.set_debuglevel(1) | |
ftp.retrbinary("RETR AutoIndent.pyc", f.write) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Закачка файла на сервер | |
""" | |
import ftplib | |
ftp = ftblib.FTP("ftp.yourServer.com") | |
ftp.login("username", "password") | |
filename = "index.html" | |
ftp.storlines("STOR " + filename, open(filename)) | |
filename="app.exe" | |
ftp.storbinary("STOR " + filename, open(filename, "rb"), 1024) | |
ftp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment