Ftplib模块的用法


  • login(user='',passwd='', acct='') 登录到FTP 服务器,所有的参数都是可选的
  • pwd() 当前工作目录
  • cwd(path) 把当前工作目录设置为path
  • dir([path[,...[,cb]]) 显示path 目录里的内容,可选的参数cb 是一个回调函数,会被传给retrlines()方法
  • nlst([path[,...]) 与dir()类似,但返回一个文件名的列表,而不是显示这些文件名
  • retrlines(cmd [, cb]) 给定FTP 命令(如“RETR filename”),用于下载文本文件。可选的回调函数cb 用于处理文件的每一行
  • retrbinary(cmd, cb[,bs=8192[, ra]]) 与retrlines()类似,只是这个指令处理二进制文件。回调函数cb 用于处理每一块(块大小默认为8K)下载的数据。
  • storlines(cmd, f) 给定FTP 命令(如“STOR filename”),以上传文本文件。要给定一个文件对象f
  • storbinary(cmd, f[,bs=8192]) 与storlines()类似,只是这个指令处理二进制文件。要给定一个文件对象f,上传块大小bs 默认为8Kbs=8192])
  • rename(old, new) 把远程文件old 改名为new
  • delete(path) 删除位于path 的远程文件
  • mkd(directory) 创建远程目录

此处给出官方给的介绍

  • Methods defined here:
  • |  
  • |  __init__(self, host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=<object object>, source_address=None)
  • |  
  • |  auth(self)
  • |      Set up secure control connection by using TLS/SSL.
  • |  
  • |  login(self, user='', passwd='', acct='', secure=True)
  • |  
  • |  ntransfercmd(self, cmd, rest=None)
  • |  
  • |  prot_c(self)
  • |      Set up clear text data connection.
  • |  
  • |  prot_p(self)
  • |      Set up secure data connection.
  • |  
  • |  retrbinary(self, cmd, callback, blocksize=8192, rest=None)
  • |  
  • |  retrlines(self, cmd, callback=None)
  • |  
  • |  storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None)
  • |  
  • |  storlines(self, cmd, fp, callback=None)

转载于:https://www.cnblogs.com/zhy128/p/8042804.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
// FTPServer.h: interface for the CFTPServer class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_FTPSERVER_H__144E8B64_2004_4709_B55A_242FE5F07BD2__INCLUDED_) #define AFX_FTPSERVER_H__144E8B64_2004_4709_B55A_242FE5F07BD2__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "ConnectThread.h" #include "ListenSocket.h" #include "FTPEventSink.h" #include "UserManager.h" #include "SecurityManager.h" class CFTPServer : public CWnd { friend CConnectSocket; public: void SetGoodbyeMessage(LPCTSTR lpszText); void SetWelcomeMessage(LPCTSTR lpszText); void SetTimeout(int nValue); void SetPort(int nValue); void SetMaxUsers(int nValue); void SetStatisticsInterval(int nValue); BOOL IsActive(); void Stop(); BOOL Start(); CFTPServer(); virtual ~CFTPServer(); CUserManager m_UserManager; CSecurityManager m_SecurityManager; CCriticalSection m_CriticalSection; // list of thread pointers CTypedPtrList<CObList, CConnectThread*> m_ThreadList; int GetPort() { return m_nPort; }; int GetMaxUsers() { return m_nMaxUsers; } int GetTimeout() { return m_nTimeout; } int GetConnectionCount() { return m_nConnectionCount; } CString GetWelcomeMessage() { return m_strWelcomeMessage; }; CString GetGoodbyeMessage() { return m_strGoodbyeMessage; }; void AddTraceLine(int nType, LPCTSTR pstrFormat, ...); private: // socket member that listens for new connections CListenSocket m_ListenSocket; CFTPEventSink *m_pEventSink; int m_nPort; int m_nMaxUsers; CString m_strWelcomeMessage; CString m_strGoodbyeMessage; int m_nTimeout; BOOL m_bRunning; // statistics DWORD m_dwTotalReceivedBytes; DWORD m_dwTotalSentBytes; int m_nConnectionCount; int m_nTotalConnections; int m_nFilesDownloaded; int m_nFilesUploaded; int m_nFailedDownloads; int m_nFailedUploads; // Operations public: BOOL IsIPAddressAllowed(LPCTSTR lpszIPAddress); void SetSecurityMode(BOOL bBlockSpecific = TRUE); BOOL CheckMaxUsers(); void Initialize(CFTPEventSink *pEventSink); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFTPServer) //}}AFX_VIRTUAL // Generated message map functions protected: int m_nSecurityMode; int m_nStatisticsInterval; //{{AFX_MSG(CFTPServer) afx_msg void OnTimer(UINT nIDEvent); //}}AFX_MSG LRESULT OnThreadClose(WPARAM wParam, LPARAM lParam); LRESULT OnThreadStart(WPARAM wParam, LPARAM); LRESULT OnThreadMessage(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() }; #endif // !defined(AFX_FTPSERVER_H__144E8B64_2004_4709_B55A_242FE5F07BD2__INCLUDED_)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值