s.write('GH') .net
print s.read() 指针
# 将输出abcDEFGH 对象
print s.getvalue() blog
经过例子,咱们看到了StringIO的行为,基本与file一致。StringIO提供了一个方法,能够方便的获取其中的数据:StringIO. getvalue()。若是使用read方法获取其中的数据,必须经过seek先设置"文件指针"的位置。get
转载自:http://blog.csdn.net/piaoyidage/article/details/42098911it