- Python标准库--io
- Python好的文章Linux IO模式及 select、poll、epoll详解
- Python代码片段
- Python读书--None
- Python框架相关--flask请求生命周期
- Python项目相关--fy
- Python之外--书单
python标准库 io
- basic
import io
# Writing to a buffer
output = io.StringIO()
output.write('This goes into the buffer. ')
print('And so does this.', file=output)
# Retrieve the value written
print(output.getvalue())
output.close() # discard buffer memory
# Initialize a read buffer
input = io.StringIO('Inital value for read buffer')
# Read from the buffer
print(input.read())