图片转码生成base64
调用接口时传参会需要用到图片转码生成base64,就在百度上找了一个copy过来,记着以后或许会经常用到!
image_path = "D:/untitled/ETC/file/1.jpg"
with open(image_path, 'rb') as f:
image = f.read()
image_base64 = str(base64.b64encode(image), encoding='utf-8')
print("呵呵")
print(image_base64)

浙公网安备 33010602011771号