Home > Backend Development > Python Tutorial > python获得图片base64编码示例

python获得图片base64编码示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-16 08:45:39
Original
1324 people have browsed it

 

复制代码 代码如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, base64

icon = open('ya.png','rb')
iconData = icon.read()
iconData = base64.b64encode(iconData)
LIMIT = 60
liIcon = []
while True:
        sLimit = iconData[:LIMIT]
        iconData = iconData[LIMIT:]
        liIcon.append('\'%s\'' %sLimit)
        if len(sLimit)                 break
print os.linesep.join(liIcon)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template