TypeError: cannot use a string pattern on a bytes-like object解决方法
来源:互联网 发布:netstat查看端口占用 编辑:程序博客网 时间:2024/04/19 23:52
因为Python2转Python3的原因,《机器学习实战》第4章的
emailText = open('email/ham/6.txt').read()需要改为
emailText = open('email/ham/6.txt','rb').read()但之后调用
listOfTokens = regEx.split(emailText)
会出现
TypeError: cannot use a string pattern on a bytes-like object上网搜索后发现可以用下面方式解决:
emailText = emailText.decode('GBK')或直接
emailText = open('email/ham/6.txt','rb').read().decode('GBK')
2 0
- TypeError: cannot use a string pattern on a bytes-like object解决方法
- 网站地图爬虫章节遇到 TypeError: cannot use a string pattern on a bytes-like object
- 一劳永逸解决:TypeError: cannot use a string pattern on a bytes-like object
- _compile(pattern, flags).findall(string) TypeError: cannot use a string pattern on a bytes-like
- TypeError: can't use a string pattern on a bytes-like object
- TypeError:can't use a string pattern on bytes-like object
- python3 爬虫时遇到问题:cannot use a string pattern on a bytes-like object
- Python学习笔记:学习爬虫时遇到的问题TypeError: cannot use a string pattern on a bytes-like object 与解决办法
- Python 出现 can't use a string pattern on a bytes-like object
- can't use a string pattern on a bytes-like object
- Python 出现 can't use a string pattern on a bytes-like object
- python中‘can't use a string pattern on a bytes-like object’错误
- can't use a string pattern on a bytes-like object错误和must be str, not bytes错误
- TypeError: a bytes-like object is required, not 'str'
- python3 TypeError: a bytes-like object is required, not 'str'
- python3 TypeError: a bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- Thread和Runnable的真正区别
- 操作系统实验一之进程管理源代码
- Java Executor并发框架(六)Executor框架线程池任务执行全过程(上)
- COCOS2DX 在vs上编译.cpp文件报错 error C2065: “”: 未声明的标识符
- browser-sync自动刷新-前端利器
- TypeError: cannot use a string pattern on a bytes-like object解决方法
- JSON-RPC(jsonrpc4j)使用demo
- 获取版本号[[NSBundle mainBundle] infoDictionary]
- C++加载csb文件
- redis 学习笔记(1)-编译、启动、停止
- python 正则表达式
- Android学习笔记—— EventBus 源码解析
- android 调用webservice保持session
- JSON-RPC轻量级远程调用协议介绍及使用