Python之base64模块使用 发表于 2014-02-01 | 分类于 Python Base64是最常见的二进制编码方法, 用64个字符来表示任意二进制数据。 主要方法 b64encode():将字符串进行base64编码 b64decode(): base64解码 代码测试12345678910111213141516# encoding=utf-8# base64模块import loggingimport base64logging.basicConfig(level = logging.DEBUG, format='%(levelname)s - %(message)s')logger = logging.getLogger(__name__)msg = 'hello world'msg64 = base64.b64encode(msg)logger.debug(msg64)logger.debug(base64.b64decode(msg64)) 输出结果: 12DEBUG - aGVsbG8gd29ybGQ=DEBUG - hello world 有用就打赏一下作者吧! 打赏 支付宝 本文作者: Ravior 本文链接: https://gitlib.com/page/python-base64.html 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!