#io 模块主要是提供了用于处理数据流的核心工具
'''
数据流:
文本数据流 txt i/o
二进制数据流 binary io
原始数据流 raw io
'''
#创建文本流的方式
#方式1
import io
f = io.StringIO("some initial text data")
f.close()
#方式2
f=open("a.txt","r",encoding="utf-8")
#16.2.1.2. Binary I/O (also called *buffered I/O*)
'''
The easiest way to create a binary stream is with "open()" with "'b'"
in the mode string:
'''
f = open("myfile.jpg", "rb")
# In-memory binary streams are also available as "BytesIO" objects:
f = io.BytesIO(b"some initial binary data: \x00\x01")
## 16.2.1.3. Raw I/O
#禁用无无缓冲io流的方式
f = open("myfile.jpg", "rb", buffering=0)
# High-level Module Interface 高级模块接口
"""
io.DEFAULT_BUFFER_SIZE
An int con
pythone IO.py 文件源代码
最新推荐文章于 2024-05-26 06:15:00 发布