Python 报错TypeError: expected string or bytes-like object
问题描述:Python 中报错TypeError: expected string or bytes-like object
解决方法:根据报错上方的提示信息,大体猜测到可能出错的具体地方。出现该报错一般为数据类型不匹配造成的,可以通过print(type(object))来查当前的数据类型,式中object为要查询的对象。
print(type(xml_data.xpath('/html/head/script[5]/text()')))
输出结果:
<class 'list'>
因此上述xpath获取的数据可考虑采用下述方式进行使用
xml_data.xpath('/html/head/script[5]/text()')[0]
Python 报错TypeError: expected string or bytes-like object相关推荐
- python报错 TypeError: an integer is required
问题描述: 在本地使用socket向NetAssist传送数据的时候,执行python文件后发现报出python 报错TypeError: an integer is required错误 代码: 1 ...
- python3报错 TypeError: can’t concat bytes to str 原因与解决方法
在做项目的时候,Python3会报错如下错误: TypeError: can't concat bytes to str 意思是: 类型错误:无法将字节连接到字符串 类似的错误有: TypeError ...
- Python报错TypeError: 'str' object is not callable
原文:http://blog.sina.com.cn/s/blog_71f3890901017rsh.html Python报错TypeError: 'str' object is not calla ...
- Python报错TypeError: ‘User‘ object is not iterable
Python报错TypeError: 'User' object is not iterable 原因 User对象是不可迭代的,我这里是因为User并不是list,所以是不可迭代的,所以不使用迭代即 ...
- Python报错 TypeError: Descriptors cannot not be created directly
Python报错TypeError: Descriptors cannot not be created directly 具体错误: TypeError: Descriptors cannot no ...
- Python报错TypeError: Descriptors cannot not be created directly
Python报错TypeError: Descriptors cannot not be created directly 具体错误: TypeError: Descriptors cannot no ...
- python报错TypeError: must be str, not int
python报错TypeError: must be str, not int 字符串拼接一个整型变量报错,代码如下 for i in range(1,586):res = 'test' + i 报错 ...
- [cx_oracle]报错:expecting string or bytes object
目标:将dataframe直接批量插入Oracle数据库 语句: # coding=utf-8 #设置语言环境 import os os.environ['NLS_LANG'] = 'SIMPLIFI ...
- react native报错:Expected a component class,got[object object]
正在写RN的视图部分,突然模拟器报错:Expected a component class,got[object object].找也找不到原因.后来才发现是自己粗心大意造成的. 错误代码: < ...
最新文章
- 【读书笔记】iOS-属性
- Python 模块之 time datetime
- 变频器服务器电路板维修,变频器电路板维修技巧
- 微软服务器延迟,经过六个多月的延迟,微软终于推出Hyper-V Server 2019
- install numpy for arm64
- 学习《Python核心编程》做一下知识点提要,方便复习(二)
- linux常用命令练习:wc、cut、|、tee、tail
- TestComplete自动化测试视频教程
- 计算机无纸化考试合卷答题笔记卡,中级会计职称无纸化答题技巧
- 如何在 Mac 上映射网络驱动器
- aix curl 安装_命令行下载工具(Curl)
- 保存为UTF-8格式的Txt文件
- qt button clicked(bool) always false
- 两张MD5值一样但实际不一样的图片
- 批量安装windows系统补丁包
- 今日学习在线编程题:弓形半径
- 如何将台式机的网络共享给另外一台台式机
- 为什么自建 UI 框架?
- C++贪吃蛇的简单实现版
- 树莓派3B——Mailbox
热门文章
- 解决url中特殊字符截断参数的问题
- Handshake failed due to invalid Upgrade header: null 解决方案
- 自监督学习推荐系统综述: 150篇自监督推荐系统文献概述四大类方法(含开源算法库SELFRec)...
- 【实践】预训练模型在华为信息流推荐中的应用与探索.pdf(附下载链接)
- 【报告分享】2020企业精细化运营白皮书.pdf(附下载链接)
- java递归mysql生成树_java递归生成树结构的数据
- asp系统转换php系统时间函数,window_Asp常用通用函数之生成时间的整数,'函数名:GetMyTimeNumber()' - phpStudy...
- java中的几个“区别”总结
- TensorBoard 1.15.0 at http://DESKTOP-DV74NQ2:6006/ 打开html后无法展示解决方案
- 该设备或资源(Web代理)未设置为接受端口“7890“上的连接解决方案