我假设您只有base64部分保存在名为的变量中
data。您要使用Python的binascii模块。
from binascii import a2b_base64data = 'MY base64-ENCODED STRING'binary_data = a2b_base64(data)fd = open('image.png', 'wb')fd.write(binary_data)fd.close()无需PIL!(谢天谢地! :)

我假设您只有base64部分保存在名为的变量中
data。您要使用Python的binascii模块。
from binascii import a2b_base64data = 'MY base64-ENCODED STRING'binary_data = a2b_base64(data)fd = open('image.png', 'wb')fd.write(binary_data)fd.close()无需PIL!(谢天谢地! :)