上善若水

水善利万物而不争
随笔 - 175, 文章 - 0, 评论 - 10, 阅读 - 14万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

 你这样

复制代码
import base64
str1 = "this is string example"
print (str1)
str1 = str1.encode(encoding ='utf-8',errors = 'strict') # 先转成bytes 的string
print (str1)
str2= base64.b64encode(str1)                            # 再使用base64.b64encode
print (str2)
enstr =base64.b64decode(str2)                           # 解密  base64.b64decode
print(enstr)
enstr =enstr.decode()
print(enstr)
复制代码

 

输入结果:

1
2
3
4
5
this is string example
b'this is string example'
b'dGhpcyBpcyBzdHJpbmcgZXhhbXBsZQ=='
b'this is string example'
this is string example

  

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示