python use the string as not string -
this question has answer here:
i url this
response.url
i more date response.
i wonder if there way in can pass things want , use in response this:
x = 'url' return response.x
you can use getattr
:
x = "url" return getattr(response, x)
from docs:
getattr(object, name[, default])
return value of named attribute of object.
name
must string. if string name of 1 of object’s attributes, result value of attribute. example,getattr(x, 'foobar')
equivalentx.foobar
. if named attribute not exist,default
returned if provided, otherwiseattributeerror
raised.
Comments
Post a Comment