TypeError: expected bytes-like object, not str
报错内容:TypeError: expected bytes-like object, not str
例:
- a = base64.b64encode(temp)
改为:
- a = base64.b64encode(bytes(temp, 'utf-8'))
问题解决!
TypeError: expected bytes-like object, not str的更多相关文章
- Python之scrapy框架之post传输数据错误:TypeError: to_bytes must receive a unicode, str or bytes object, got int
错误名:TypeError: to_bytes must receive a unicode, str or bytes object, got int 错误翻译:类型错误:to_bytes必须接收u ...
- python中读取json文件报错,TypeError:the Json object must be str, bytes or bytearray,not ‘TextIOWrapper’
利用python中的json读取json文件时,因为错误使用了相应的方法导致报错:TypeError:the Json object must be str, bytes or bytearray,n ...
- python写入文本报错TypeError: expected a string or other character buffer object
今天用python写入文本, file_object2 = open('result.txt', 'w') file_object2.write(bookid_list) file_object2.c ...
- socket编程: TypeError: must be bytes or buffer, not str
先看一段代码 #!/usr/bin/env python3 from socket import * serverName = "10.10.10.132" serverPort ...
- 关于TypeError: strptime() argument 1 must be str, not bytes解析
关于TypeError: strptime() argument 1 must be str, not bytes解析 在使用datetime.strptime(s,fmt)来输出结果日期结果时, ...
- python TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str'
TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str' if self.params[ ...
- 导入json文件报错,TypeError expected string or buffer
导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...
- 解决:error: Cannot fetch repo (TypeError: expected string or buffer)
同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...
- Python报错TypeError: '<' not supported between instances of 'str' and 'int'
n = input() if n>=100:print(int(n)/10) else:print(int(n)*10) 报错内容: Traceback (most recent call la ...
随机推荐
- Yum:更换aliyun的yum源
备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup centos7 wget -O /et ...
- NioEventLoop.run select处理IO事件(boss/worker)流程:
NioEventLoop.run select处理IO事件(boss/worker)流程:processSelectedKeysprocessSelectedKeysOptimizedprocessS ...
- 32道常见的Java基础面试题
1. 什么是 Java 虚拟机(JVM)?为什么 Java 被称作是“平台无关的编程语言”? Java 虚拟机是一个可以执行 Java 字节码的虚拟机进程.Java 源文件被编译成能被 Java 虚拟 ...
- Spring之HelloWorld
[Spring是什么?] 1.Spring是一个开源框架. 2.Spring为简化企业级应用开发而生,使用Spring可以使简单的JavaBean实现以前只有EJB(EJB是sun的JavaEE服务器 ...
- Android SwipeSelector
Android SwipeSelector Android SwipeSelector是github上一个第三方开源的项目,其项目主页:https://github.com/roughike/S ...
- URAL 1297 求最长回文字符串
有种简单的方法,数组从左到右扫一遍,每次以当前的点为中心,只要左右相等就往左右走,这算出来的回文字符串是奇数长度的 还有偶数长度的回文字符串就是以当前扫到的点和它左边的点作为中心,然后往左右扫 这是O ...
- 【转】关于LIS和一类可以用树状数组优化的DP 预备知识
原文链接 http://www.cnblogs.com/liu-runda/p/6193690.html 预备知识 DP(Dynamic Programming):一种以无后效性的状态转移为基础的算法 ...
- node.js里的buffer常见操作,copy,concat等实例讲解
//通过长度构建的buffer内容是随机的 var buffer=new Buffer(100); console.log(buffer); //手动清空buffer,一般创建buffer不会清空 b ...
- 【ZJOI2017 Round1练习】D4T2 trie(贪心,状压DP)
题意:现在 Matej 手上有 N 个英文小写字母组成的单词, 他想知道,如果将这 N 个单词中的字母分别进行重新排列,形成的字母树的节点数最少是多少. n<=16,len[i]<=100 ...
- Elasticsearch自定义客户端(TransportClient)资源池
前言: java中调用TransportClient时,我们一般都会设置成单例,为了避免多次的创建与关闭造成的内存占用及关闭缓慢问题.而TransportClient本身也是实现了线程池threadP ...