img_urlcode.py 332 B

123456789101112131415
  1. # @Author : lightXu
  2. # @File : img_urlcode.py
  3. import base64
  4. def img2base64(img):
  5. base64_data = base64.b64encode(img)
  6. print(base64_data)
  7. return base64_data
  8. if __name__ == '__main__':
  9. img_path = r'C:\Users\Administrator\Desktop\history\0002.jpg'
  10. with open(img_path, 'rb') as f:
  11. img2base64(f.read())