python基础:字符串编码与解码

 时间:2026-05-06 22:10:24

1、打开Python3.7交互界面

python基础:字符串编码与解码

2、定义字符串变量

str = 'this is a encode and decode test'

python基础:字符串编码与解码

3、用encode()方法进行GBK编码

newStr = str.encode('GBK')

python基础:字符串编码与解码

4、打印输出

python基础:字符串编码与解码

5、同时我可以对newStr进行解码

newStr.decode('AsCII')

python基础:字符串编码与解码

1、1.encode()进行编码

2.decode()进行解码

3.编解码尽量保持一致


  • python的字符串内建函数2
  • python中如何获得字符串的编码整数?
  • python检查编码方式chardet用法
  • python的字符串内建函数1
  • python的字符串内建函数12
  • 热门搜索
    激素脸怎么办 口腔溃疡怎么好得快 空间怎么设置访问权限 孕妇扁桃体发炎怎么办 爆胎怎么办 你怎么舍得我难过简谱 雀巢淡奶油怎么打发 人死了会怎么样 不粘锅粘锅了怎么办 吸顶灯怎么拆