This page needs to be cached! Bug Report Hit! Js中atob和btoa在Python中等效函数表达 - PCYO - 你是谁的,谁是谁,谁为谁憔悴

PCYOPCYO

飞鸟

Js中atob和btoa在Python中等效函数表达

Javascript函数

atob("待解码字符串")
btoa("待编码字符串")

Python表达等效函数

import base64
# atob
s = base64.b64decode("待解码的字符".encode("utf8")).decode("latin1")
# btoa
s = base64.b64encode("待编码的字符".encode("latin1")).decode("utf8")

原因解释:

Python中字符串中的Latin1编码与Javascript的binary编码相同

本原创文章未经允许不得转载 | 当前页面:PCYO » Js中atob和btoa在Python中等效函数表达

评论

This page loaded in 0.001474 seconds