使用Python2.7版本.以下是我的示例代码.
import StringIO import sys buff = StringIO.StringIO() buff.write("hello") print buff.read()
在上面的程序中,read()不返回任何内容,因为getvalue()返回"hello".任何人都可以帮我解决问题吗?我需要read(),因为我的以下代码涉及读取"n"字节.
python stringio
python ×1
stringio ×1