How can I see if a child exists in Python?
I have an lxml
object called item
and 开发者_运维问答it may have a child called item.brand
, however it's possible that there is none as this is returned from an API. How can I check this in Python?
Try hasattr()
.
精彩评论