如何在Python中忽略/覆盖setter?

时间:2017-11-10 03:47:33

标签: python python-3.x python-requests

我有一个请求响应对象 r r 作为参数传递给回调函数。我想对 r.text 执行操作,然后返回完整的 r 对象。

但是,当我尝试重新分配 r.text 时,

AttributeError: can't set attribute

被抛出

1 个答案:

答案 0 :(得分:1)

text属性是propery,没有setter。 如果要修改它,则应将其复制到新变量中:

from copy import copy
my_text = copy(r.text)