pthon
微风行者
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
TypeError: a bytes-like object is required, not 'str'
新手学习python,3.0中部分函数参数需要bytes,如果使用str会报告TypeError: a bytes-like object is required, not ‘str’的错误避免以上错误,需要在字符串前增加b将str转换为bytes原创 2017-01-24 19:29:45 · 11859 阅读 · 2 评论 -
urllib.urlopen已替换为urllib.request.urlopen()
python3已经将2.6之前的urllib.urlopen停用,现已替换为urllib.request.urlopen(). 使用webpage.read()读取的页面内容text内容为bytes-object,打印内容为b’……‘ ,无法直接使用到re.search(),使用前需要转换为string类型。 text为bytes-object,将其转换为字符串text.decode(),默认原创 2017-01-25 17:09:23 · 2723 阅读 · 0 评论
分享