#-*- coding: utf-8 -*- import base64 str = 'cnblogs' str64 = base64.b64encode(str) print str64 #Y25ibG9ncw== print base64.b64decode(str64) #cnblogs