Is there a good way to check if a string is encoded in base64
using Python?
相关问题
- Views base64 encoded blob in HTML with PHP
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
if the length of the encoded string is the times of 4, it can be decoded
so, you just need to check if the string can match something like above, then it won't throw any exception(I Guess =.=)
In my case, my input,
s
, had newlines which I had to strip before the comparison.this code put in the result variable decoded string if x is really encoded, and just x if not. Just try to decode doesn't always work.