阅读背景:

python代码笔记3(IO/线程)

来源:互联网 

#_____________IO

<pre name="code" class="python">from io import StringIO
f = StringIO()#BytesIO  f.write('中文'.encode('utf-8'))
f.write("hello")
f.write(",world")
print(f.getvalue())

import pickle
d = dict(key1='liu',key2=23)
f = open('dump.txt','wb')
pickle.dump(d,f)
f.close
f = open('dump.txt','rb')
d = pickle.load(f)
print(d)

import json
j = json.dumps(d)
print(j)<pre name="code" c



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: