obj.style.width问题

在学习过程中发现obj.style.width怎么也获取不到容器的宽度,

经了解才知道obj.style.width只能获取行内样式,

非行内样式想要取得容器的宽度可以采用:

1.obj.offsetWidth

2.obj.clientWidth

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在这个错误信息中,'NoneType' object has no attribute 'text' 表示对象为None,即没有找到对应的标签值。具体地,obj.find('name')返回的是None。所提供的解决方案是,在使用find函数之后,添加一句判断语句,如果找不到对应的标签,就将其默认值设为0。例如,可以使用以下代码来解决这个问题: ```python if obj.find('name'): name = obj.find('name').text else: name = 0 ``` 这样,如果找不到name标签,变量name的值就会被设为0,避免了AttributeError的出现。请注意,这只是一种可能的解决方案,根据具体情况可能需要做出适当的修改。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Python学习笔记:‘’AttributeError: NoneType object has no attribute‘’](https://blog.csdn.net/lvsehaiyang1993/article/details/80910104)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [关于 AttributeError: ‘NoneType‘ object has no attribute ‘text‘ 的三种解决方法](https://blog.csdn.net/qq_55535816/article/details/121456901)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值