OS.path模块中的部分函数的介绍

  • os.path.abspath(path) #返回绝对路径
  • os.path.basename(path) #返回文件名
  • os.path.commonprefix(list) #返回list(多个路径)中,所有path共有的最长的路径。
  • os.path.dirname(path) #返回文件路径
  • os.path.exists(path) #路径存在则返回True,路径损坏返回False
  • os.path.lexists #路径存在则返回True,路径损坏也返回True
  • os.path.expanduser(path) #把path中包含的””和”user”转换成用户目录
阅读全文 »

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) 创建远程目录
阅读全文 »

服务器类型

5种类型:BaseServer,TCPServer,UnixStreamServer,UDPServer,UnixDatagramServer。注意:BaseServer不直接对外服务。

阅读全文 »
0%