python3.x 将byte转成字符串的方法

yipeiwu_com5年前Python基础

如下所示:

result = str(要转换的变量名, encoding='utf-8')

例如:

result = str(request, encoding='utf-8')

以上这篇python3.x 将byte转成字符串的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python寻找list中最大值、最小值并返回其所在位置的方法

实例如下所示: c = [-10,-5,0,5,3,10,15,-20,25] print c.index(min(c)) # 返回最小值 print c.index(max(c)...

使用Python的turtle模块画国旗

使用Python的turtle模块画国旗

Python的turtle模块画国旗主要用到两个函数:draw_rentangle和draw_star。 至于函数的调用就和我们学的C,C++是一样的。对于turtle画国旗的程序中,首...

python self,cls,decorator的理解

1. self, cls 不是关键字 在python里面,self, cls 不是关键字,完全可以使用自己写的任意变量代替实现一样的效果 代码1 复制代码 代码如下:class MyTe...

Python JSON格式数据的提取和保存的实现

环境:python-3.6.5 JSON JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,它使得人们很容易的进行阅读和编写。同时也方便了...

Python中shapefile转换geojson的示例

shapefile转换geojson import shapefile import codecs from json import dumps # read the shapefi...