利用os和base64生成随机字符串

import os
import base64

a = os.urandom(46)
b = base64.b64encode(a)
print(b) # b'yn5VoGp1+LNzG8NqjMCFfAzqWrqwj+mR1u2tCKJDaqKPnMGCHMFruazlQAG4Hg=='
print(b.decode('utf-8')) # yn5VoGp1+LNzG8NqjMCFfAzqWrqwj+mR1u2tCKJDaqKPnMGCHMFruazlQAG4Hg==
posted @ 2018-12-20 21:57  Ksitigarbha  阅读(470)  评论(0编辑  收藏  举报