代码实例讲解python3的编码问题

上传:szp32142 浏览: 16 推荐: 0 文件:PDF 大小:101.57KB 上传时间:2021-01-04 00:21:14 版权申诉
python3的编码问题。 打开python开发工具IDLE,新建‘codetest.py’文件,并写代码如下: import sys print (sys.getdefaultencoding()) F5运行程序,打印出系统默认编码方式 将字符串从str格式编码程bytes格式,修改代码如下: import sys print (sys.getdefaultencoding()) s = '你好' print (type(s)) b = s.encode('utf-8') print (type(b)) print (b) 其中b = s.encode(‘utf-8’) 等同
上传资源
用户评论