我在想如果是相關的導入正是我需要從模塊爲了減少任何腳本的內存消耗,或者我應該只是導入一切?我相信如果我開始寫這種方式可以消耗更多的時間寫,但它值得嗎?我的意思是,可以減少更多使用內存的機會?導入完整模塊或只是我需要爲了減少內存
隨着代碼波紋管,一個tleast只是相關部分是什麼IM規劃做一個當前的例子:
from ftplib import FTP as FTP_LIB
from ftplib.FTP import connect as FTP_CONNECT
from ftplib.FTP import login AS FTP_LOGIN
from ftplib.FTP import cwd as FTP_CWD
from ftplib.FTP import storbinary as FTP_STORE_BIN
from ftplib.FTP import retrbinary as FTP_RETRIV_BIN
from ftplib.FTP import delete as FTP_DELETE
from ftplib.FTP import quit as FTP_QUIT
from zipfile import ZipFile
from zipfile import ZIP_DEFLATED
from sys import exit as SYS_EXIT
#--------------------------------------------------------------------------
# FTP Download
#--------------------------------------------------------------------------
def get_file(self, iServer, ftpPort, login, pwd, fileName, path):
parts = iServer.split(":")
host = parts[0]
ftp = FTP_LIB()
try:
FTP_CONNECT(host, ftpPort, 20)
FTP_LOGIN(login, pwd)
FTP_CWD(path)
FTP_RETRIV_BIN('RETR ' + fileName, open(fileName, 'wb').write)
except Exception, e:
print " Download failed : " + str(e)
SYS_EXIT(1)
finally:
FTP_QUIT()
在此先感謝。
跨站點重複數據刪除:['導入模塊「從模塊導入功能」與(http://programmers.stackexchange.com/ q/187403) –