---
title: "python 3改写base64编码"
author: "tjzzy"
date: "2016-02-24T15:24:03Z"
tags: []
categories: ["编程语言"]
slug: "python-3-base64"
draft: false
lastmod: "2016-02-24T15:24:03Z"
id: 2278580
url: "https://tjzzy.iteye.com/blog/2278580"
---

本来python有base64这个模块，挺方便的，但是python3里面无一例外的又改变了参数格式，并且无一例外的@#￥……&于是我就改写了一下最简单的程序，需要encoding了，清单如下：

 

import base64

s = "hello被子64"

a = base64.b64encode(bytes(s,encoding="utf-8"))

print(a)

#解码，将bytes转换回string

print(str(base64.b64decode(a),encoding="utf-8"))