今天学习了文件中读写和内存中的读写
文件中读写用with open ('路径','r') as f :
print(f.read())
with open ('路径','r') as f :
f.write('写的内容')
在内存中读写则用StringIO
from io import StringIO
f = StringIO()
f.write('山雨欲来风满楼')
print(f.getvalue())
今天学习了文件中读写和内存中的读写
文件中读写用with open ('路径','r') as f :
print(f.read())
with open ('路径','r') as f :
f.write('写的内容')
在内存中读写则用StringIO
from io import StringIO
f = StringIO()
f.write('山雨欲来风满楼')
print(f.getvalue())