在Python2中实现了如下一段代码:
from sys import stdout
def write(s):
old_write(s)
try:
old_write,stdout.write = stdout.write, write
finally:
del stdout.write
结果得到如下1个错误:
AttributeError: 'file' object attribute 'write' is read-only
对上述代码要进行如何的修改才能正常运行。