【发布时间】:2017-03-14 15:53:53
【问题描述】:
我有以下代码:
>>> import io
>>> b = io.BytesIO(b"Hello World")
>>> f = io.TextIOWrapper(b)
>>> f.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
io.UnsupportedOperation: fileno
但是,当我加载一个文件时,有一个fileno 属性:
>>> f = open("test.py")
>>> f.fileno()
3
有没有办法为第一种情况创建fileno 属性,我将BytesIO 对象转换为TextIOWrapper 对象?
【问题讨论】: