用到了python里的base64模块

用法:

编码:

1 import base64
2 a = 'HC'.decode() #将‘HC’转为二进制
3 b = base64.b64encode(a) #将a转为base64编码
4 b.decode() #从二进制转回
5 
6 base64.b64encode('HC'.encode()).decode() #简写
'SEM=

解码:

base64.b64decode('SEM=').decode()
'HC'

 

其他常用函数:

chr(x) 将十进制转换为ASCII中相应的字符

ord(x) 将ASCII中相应的字符转换为十进制数

1 chr(65)
'A'
3 ord('A')
65

 

相关文章:

  • 2021-10-02
  • 2022-12-23
  • 2021-08-17
  • 2022-03-01
  • 2023-02-26
  • 2023-03-18
  • 2022-12-23
猜你喜欢
  • 2021-06-11
  • 2021-10-01
  • 2021-07-14
  • 2021-12-21
相关资源
相似解决方案