import io f = io.StringIO() f.write("") f.getvalue() f.close 二进制 f = io.Bytesio() 转载于:https://www.cnblogs.com/cxhzy/p/9892797.html