Skip to main content
 首页 » 编程设计

python之给定一个字符串,我怎么知道它是否需要解码

2025年05月04日19Renyi-Fan

我正在使用 python 的 base64 模块,我得到了一个可以编码或不编码的字符串。我想做类似的事情:

if isEncoded(s): 
   output = base64.decodestring(s) 
else: 
   output = s 

想法?

请您参考如下方法:

一般来说,这是不可能的;例如,如果您收到字符串“MjMj”,您怎么可能知道它是否已经解码并需要按原样使用,或者解码为“23#”?