三种I/O类型

  • Binary: expects and produces bytes objects, 不会编解码,不会换行
  • Text: expects and produces str objects, 自动编解码和换行
  • Raw(unbuffered): uilding-block for binary and text streams

底层类

  • 抽象基类IOBase: 无read/write方法
  • RawIOBase: raw binary I/O
  • BufferedIOBase: binary stream

Buffered Sreams

  • BytesIO: an in-memory buffer bytes stream
  • StringIO: an in-memory buffer str stream

select

  • select: 用法 select([read_fds, write_fds, exception_fds], timeout), select要求fileno小于1024
  • poll

selectors

  • 按位来区分订阅的事件类型: READ :1, WRITE: 2, READWRITE: 3
  • SelectSelector: 使用select获取fds的状态
  • PollSelector: 使用poll获取fds的状态
  • EpollSelector: 使用epoll获取fds的状态

参考