郞性人生

导航

python 将字典转为bytes类型字典

sDict = {"key1": 20, "key2": "123456", "key3": [1544]}
bytesDict = bytes('{}'.format(sDict),'utf-8')
print(bytesDict) # b"{'key1': 20, 'key2': '123456', 'key3': [1544]}"

posted on 2020-09-11 18:42  郞性人生  阅读(3364)  评论(0编辑  收藏  举报