开发者

How can I see if a child exists in Python?

开发者 https://www.devze.com 2023-01-28 06:48 出处:网络
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?Tr

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消