今天学习IO模块的使用,主要分为StringIO的使用和BytesIO的使用~
# 类似文件的缓冲区
from io import StringIO
cache_file = StringIO()
print(cache_file.write('hello world')) # 11
print(cache_file.seek(0)) # 0
print(cache_file.read()) # hello world
print(cache_file.close()) # 释放缓冲区
# 类似文件的缓冲区
from io import BytesIO
bytes_file = BytesIO()
bytes_file.write(b'hello world')
bytes_file.seek(0)
print(bytes_file.read()) # b'hello world'
bytes_file.close()
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款