[英]How to ignore/overwrite setters in Python?
I have a Requests response object, r . 我有一个Requests响应对象r 。 r gets passed into a callback function as an argument.
r被作为参数传递给回调函数。 I want to perform an action on r.text , and then return the full r object.
我想对r.text执行操作,然后返回完整的r对象。
However, when I try to reassign r.text , 但是,当我尝试重新分配r.text时 ,
AttributeError: can't set attribute
is thrown 被抛出
The text
attribute is a propery
without setter. 该
text
属性是一个propery
不二传手。 If you want to modify it, you should copy it to a new variable like this: 如果要修改它,则应将其复制到新变量中,如下所示:
from copy import copy
my_text = copy(r.text)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.