import base64
import StringIO
a = "this is a test"
b = base64.encodestring(a)
print b
print base64.decodestring(b)
c = StringIO.StringIO()
c.write(a)
d = StringIO.StringIO()
e = StringIO.StringIO()
c.seek(0)
base64.encode(c, d)
print d.getvalue()
d.seek(0)
base64.decode(d, e)
print e.getvalue()
a = "this is a +test"
b = base64.urlsafe_b64encode(a)
print b
print base64.urlsafe_b64decode(b)
import StringIO
a = "this is a test"
b = base64.encodestring(a)
print b
print base64.decodestring(b)
c = StringIO.StringIO()
c.write(a)
d = StringIO.StringIO()
e = StringIO.StringIO()
c.seek(0)
base64.encode(c, d)
print d.getvalue()
d.seek(0)
base64.decode(d, e)
print e.getvalue()
a = "this is a +test"
b = base64.urlsafe_b64encode(a)
print b
print base64.urlsafe_b64decode(b)
本文详细介绍了如何使用Python的base64模块进行字符串的Base64编码与解码,并通过实例展示了如何在不同上下文中应用这些功能。
3万+

被折叠的 条评论
为什么被折叠?



