我有一个PDF作为base64字符串,我需要使用Python将其写入文件。我尝试了这个:
import base64
base64String = "data:application/pdf;base64,JVBERi0xLjQKJeHp69MKMSAwIG9iago8PC9Qcm9kdWNlciAoU2tpYS9..."
with open('temp.pdf', 'wb') as theFile:
theFile.write(base64.b64decode(base64String))
Run Code Online (Sandbox Code Playgroud)
但是它没有创建有效的PDF文件。我想念什么?