小编raj*_*raj的帖子

无法在python中使用StringIO的read()获取数据

使用Python2.7版本.以下是我的示例代码.

import StringIO
import sys

buff = StringIO.StringIO()
buff.write("hello")
print buff.read()
Run Code Online (Sandbox Code Playgroud)

在上面的程序中,read()不返回任何内容,因为getvalue()返回"hello".任何人都可以帮我解决问题吗?我需要read(),因为我的以下代码涉及读取"n"字节.

python stringio

64
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1

stringio ×1