Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 889 Bytes

day23.md

File metadata and controls

30 lines (25 loc) · 889 Bytes

第二十三天

索引

python标准库 io

  1. 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())