1 #!/user/bin/env python
2 # -*- coding:utf-8 -*-
3 
4 temp = "连接"
5 temp_unicode = temp.decode('utf-8')
6 temp_gbk =unicode.encode('gbk')
7 print(temp_gbk)
 1 #!/usr/bin/env python
 2 #bytes 和str 的转换
 3 a = "李璐"
 4 b1 = bytes(a,encoding='utf-8')
 5 print(b1)
 6 newa1 = str(b1,encoding='utf-8')
 7 print(newa1)
 8 b2 = bytes(a,encoding='gbk')
 9 print(b1)
10 newa2 = str(b2,encoding='gbk')
11 print(newa2)

 

 

相关文章:

  • 2021-12-23
  • 2021-11-30
  • 2021-11-30
  • 2021-10-16
  • 2022-02-04
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-07-26
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案