response.read() returns an instance of bytes while StringIO is an in-memory stream for text only. Use BytesIO instead.

The StringIO and cStringIO modules are gone. Instead, import the io module and use io.StringIO or io.BytesIO for text and data respectively.

Python3 TypeError: initial_value must be str or None, not bytes的更多相关文章

  1. python3 TypeError: a bytes-like object is required, not 'str'

    在学习<Python web开发学习实录>时, 例11-1: # !/usr/bin/env python # coding=utf-8 import socket sock = sock ...

  2. 转 python3中SQLLIT编码与解码之Unicode与bytes

    #########sample########## sqlite3.OperationalError: Could not decode to UTF-8 column 'logtype' with ...

  3. Python3.x:报错POST data should be bytes, an iterable of bytes

    Python3.x:报错POST data should be bytes, an iterable of bytes 问题: python3.x:报错 POST data should be byt ...

  4. python3 TypeError: 'str' does not support the buffer interface in python

    http://stackoverflow.com/questions/38714936/typeerror-str-does-not-support-the-buffer-interface-in-p ...

  5. Python3.6 AES加密 pycrypto‎ 更新为 pycrypto‎demo | TypeError: Object type <class 'str'> cannot be passed to C code

    #!/usr/bin/env python# -*- coding:utf-8 -*-# @author: rui.xu# @update: jt.huang# 这里使用pycrypto‎demo库# ...

  6. python3 TypeError: Unicode-objects must be encoded before hashing

    python3下,利用hash值对字符串进行md5加密时报错:TypeError: Unicode-objects must be encoded before hashing 原因是:python3 ...

  7. python3 字符串/列表/元组(str/list/tuple)相互转换方法及join()函数的使用

    在抓取网络数据的时候,有时会用正则对结构化的数据进行提取,比如 href="https://www.1234.com"等.python的re模块的findall()函数会返回一个所 ...

  8. python3.x 基础一:str字符串方法

    *字符串不能更改值 数据类型字符串str |  capitalize(...)   返回字符串中第一个字母大写 |      S.capitalize() -> str |       |    ...

  9. 爬虫python3:TypeError: cannot use a string pattern on a bytes-like object

    import re from common_p3 import download def crawl_sitemap(url): sitemap = download(url) links = re. ...

随机推荐

  1. Webpack的配置项

    Webpack配置选项 ​ 经历了考研以后,接下来的时间里准备捡起来这些以前学的东西,并且继续向着前端的方向出发,给自己多一条路的选择.话不多说,直接开始. moudule.exports = { / ...

  2. 知乎vscode插件修改和重新编译

    需求来源 vscode插件修改代码要怎样重新编译并安装到vscode中? 起源于我使用一个vscode插件,它可以在vscode中发布文章到知乎上,然后我修改了插件的部分源代码,希望在vscode中安 ...

  3. PHP中的PDO操作学习(二)预处理语句及事务

    今天这篇文章,我们来简单的学习一下 PDO 中的预处理语句以及事务的使用,它们都是在 PDO 对象下的操作,而且并不复杂,简单的应用都能很容易地实现.只不过大部分情况下,大家都在使用框架,手写的机会非 ...

  4. css3 横屏

    @media screen and (orientation: portrait) { html{ width : 100vmin; height : 100vmax; } body{ width : ...

  5. Java基础系列(30)- 命令行传参

    命令行传参 有时候你希望运行一个程序的时候再传递给它消息.这就要靠传递命令行参数main()函数实现 package method; public class CommandLine { public ...

  6. iOS之内存管理-字节对齐

    字节对齐 1 struct Mystruct1{ 2 char a; //1字节 3 double b; //8字节 4 int c; //4字节 5 short d; //2字节 6 }Mystru ...

  7. hibernate 初学

    1. hibernate的基本操作 执行流程: 执行流程细节:基本的配置文件         可以与mybatis进行对比着记                  hibernate 的主键生成策略   ...

  8. Redis-Cluster分片扩容

    redis分片分片场景在业务量相对较小的时候,可以将所有数据都存到一台机器上,只使用redis单机模式,不存在分片问题.如果业务的数据量超过一台物理机器的内存大小时,则会面对扩展问题,需要多台机器去存 ...

  9. Tidb使用

    一.为什么使用Tidb 最近发现tidb在互联网圈大火,新生代的一个NewSql数据库 具体链接可以访问pincap的官网  https://www.pingcap.com/docs-cn/v3.0/ ...

  10. CF1039D-You Are Given a Tree【根号分治,贪心】

    正题 题目链接:https://www.luogu.com.cn/problem/CF1039D 题目大意 给出\(n\)个点的一棵树,然后对于\(k\in[1,n]\)求每次使用一条长度为\(k\) ...