1.图片转base64,url指图片路径
def ToBase64(url): with open(url,'rb') as f: base64_data=base64.b64encode(f.read()) s=base64_data.decode() #print(url+"已转base64") return s
2.图片直接在网页打开: “data:image/gif;base64,”后面加上base64码流即可
1.图片转base64,url指图片路径
def ToBase64(url): with open(url,'rb') as f: base64_data=base64.b64encode(f.read()) s=base64_data.decode() #print(url+"已转base64") return s
2.图片直接在网页打开: “data:image/gif;base64,”后面加上base64码流即可