python读写内存数据

# -*- coding:utf-8 -*-

from io import StringIO,BytesIO

f=StringIO("Hello,EveryOne.\nMy name is Joannes.\n")
while True:
    r=f.readline()
    if r=="":
        break
    print(r.strip())


b=BytesIO("我的名字叫Joannes\n老骥伏枥,志在千里".encode('utf-8'))
while True:
    _b=b.readline()
    if _b==b"":
        break
    print(_b.decode('utf-8').strip())

  思考:读写内存数据优劣

posted @ 2020-11-12 23:28  Joooannes  阅读(492)  评论(0)    收藏  举报