python bytes to string
python bytes 转化成 string 会遇到如下错误:
codec can't decode byte 0xff in position 5: illegal multibyte sequence
其实还是编码格式的问题,通过使用: ok_cookies = ok_str.decode('iso-8859-1')
ok_str = b'\x00\x01\x00\x00\x00\xff\xff\xff\xff\x01\x00\x00\x00\x00\x00\x00\x00\x06\x01\x00\x00\x00\x83\x02JSESSIONID=T2yrYjqcymFWppsLlJRlLkKv12MFvN2XTn90LJP4d8C22bp989pb!1246418420;BIGipServerpool_xwqy=FCvoaVAFKNbKjaDKHq0URsieemJ3jdG54/DLz9FGInF+UEiDGYTJHurg+SIiST4VX9D2VdgYcwvVZ9g=;ipcrs=L7Ng5mBsLk+NqWHttzF8QSOrXK1n1gnYWmBMzGZ2Nsg0/pvY+VVMmy25y6wW1B7yR2NMBOEeTxcB\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' ok_cookies = ok_str.decode() # 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte ok_cookies = ok_str.decode('gbk') # 'gbk' codec can't decode byte 0xff in position 5: illegal multibyte sequence ok_cookies = ok_str.decode('iso-8859-1') # 可以解决
python bytes to string的更多相关文章
- [Python]Bytes 和 String转换
#----string to bytes------ # 方法一:直接复制bytes类型 b'<str>' b = b'Hello World' print(type(b)) print( ...
- Python中的string和bytes的转换
总的来说,bytes和string的关系是: \(bytes\xrightarrow{decode}string\) \(bytes\xleftarrow{encode}string\) 常见的几种编 ...
- python unicode和string byte
python unicode 和string那 开发过程中总是会碰到string, unicode, ASCII, 中文字符等编码的问题, 每次碰到都要现搜, 很是浪费时间, 于是这次狠下心, 一定要 ...
- Python bytes decode() 方法
描述 bytes decode() 方法以指定的编码格式解码 bytes 对象,默认编码为 'utf-8'. 对应的编码方法:encode() 方法 . 语法 Python bytes decode( ...
- 【RF库测试】Encode String To Bytes&Decode Bytes To String& should be string&should be unicode string &should not be string
场景1:判断类型 r ${d} set variable \xba\xcb\xbc\xf5\xcd\xa8\xb9\xfd #核减通过 Run Keyword And Continue On Fail ...
- python基础===Character string
本文转自:python之Character string 1.python字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串,l Python不支持单 ...
- Python中字符串String的基本内置函数与过滤字符模块函数的基本用法
Python中字符串String的基本内置函数与用法 首先我们要明白在python中当字符编码为:UTF-8时,中文在字符串中的占位为3个字节,其余字符为一个字节 下面就直接介绍几种python中字符 ...
- 各种转码(bytes、string、base64、numpy array、io、BufferedReader )
bytes 与 string 之间互转 Python3 最重要的新特性大概要算是对文本和二进制数据作了更为清晰的区分.文本总是 Unicode,由str类型表示,二进制数据则由 bytes 类型表示. ...
- python之bytes和string
转自:https://www.cnblogs.com/skiler/p/6687337.html 1.bytes主要是给在计算机看的,string主要是给人看的 2.中间有个桥梁就是编码规则,现在大趋 ...
随机推荐
- Asp.net MVC3表格共用分页功能
在建立的mvc3项目中,在Razor(CSHTML)视图引擎下,数据会在表格中自动的生成,但分页没有好的控件实现,这里我们开发了设计了一个分页的模板,适合于没有数据提交和有数据提交的分页的分页. 第一 ...
- [转载]Python 元组、列表、字典、文件
python的元组.列表.字典数据类型是很python(there python is a adjective)的数据结构.这些结构都是经过足够优化后的,所以如果使用好的话,在某些area会有很大的益 ...
- OpenCV 学习
#include <opencv2\opencv.hpp> #include <iostream> #include <opencv2\highgui\highgui.h ...
- 使用AjaxPro实现无刷新更新数据
需求 在一个页面动态无刷新的更新后台得到的数据.要想无刷新的更新数据,需要使用Javascript能够获取后台返回的数据,然后通过第三方Javascript库(JQuery等)动态更新web页面DOM ...
- 面试复习(C++)之基数排序
#include <iostream> using namespace std; int maxbit(int *a,int n) { ;//一位 ;//十进制 ;i<n;i++) ...
- java web学习之初识jsp
用java语言(+html语言)开发动态资源的技术: jsp的运行过程,1:tomcat服务器将jsp代码翻译成java代码,并且编译成class文件 2:tomcat服务器构造类对象 3:tomca ...
- AAS代码第2章
[root@node1 aas]# pwd /root/aas [root@node1 aas]# wget http://archive.apache.org/dist/spark/spark-1. ...
- Add listitem with javascript 分类: Sharepoint 2015-07-16 20:23 4人阅读 评论(0) 收藏
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', createListItem);//makes sure sp.js is loaded and the ...
- Delphi 有关Dbgrideh控件:变色处理
procedure OnDrawColumnCell( Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; ...
- 50个C/C++源代码网站
C/C++是最主要的编程语言.这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码 .这份清单提供了源代码的链接以及它们的小说明.我已尽力包括最佳的C/C++源代码的网站.这不是一个完整的 ...