Python之条形码生成学习笔记
2018-02-24 18:55
519 查看
首先安装pyBarcode
pip install pyBarcodefrom barcode.writer import ImageWriter
from barcode.codex import Code39
from PIL import Image, ImageDraw, ImageFont, ImageWin
imagewriter = ImageWriter()
#保存到图片中
#add_checksum : Boolean Add the checksum to code or not (default: True)
ean = Code39("1234567890", writer=imagewriter, add_checksum=False)
# 不需要写后缀,ImageWriter初始化方法中默认self.format = 'PNG'
print '保存到image.png'
ean.save('image')
img = Image.open('image.png')
print '展示image.png'
img.show()
pip install pyBarcodefrom barcode.writer import ImageWriter
from barcode.codex import Code39
from PIL import Image, ImageDraw, ImageFont, ImageWin
imagewriter = ImageWriter()
#保存到图片中
#add_checksum : Boolean Add the checksum to code or not (default: True)
ean = Code39("1234567890", writer=imagewriter, add_checksum=False)
# 不需要写后缀,ImageWriter初始化方法中默认self.format = 'PNG'
print '保存到image.png'
ean.save('image')
img = Image.open('image.png')
print '展示image.png'
img.show()
相关文章推荐
- TensorFlow学习笔记[1]: TensorFlow安装及在Jupyter notebook中用Pythond代码并生成散列点图
- 07-python学习笔记-列表生成式
- Python学习笔记 --- pip生成依赖文件说明
- Python.Numpy学习零碎笔记之随机数生成
- Python学习笔记(2):生成随机数
- python学习笔记(20)--生成点拨【已放弃】
- 【Python学习笔记】-生成激活码
- 一个无聊男人的疯狂《数据结构与算法分析-C++描述》学习笔记 用C++/lua/python/bash的四重实现(7)习题2.8 随机数组的三种生成算法
- python网络编程学习笔记(八):XML生成与解析(DOM、ElementTree)
- Python学习笔记-Day03 -第三部分(迭代器和生成简介)
- Python3学习笔记(五)--列表生成式
- python学习笔记之切片(slice)、列表生成式
- python学习笔记6—文件操作来生成船只侧面图像的描述文件
- Python开发学习笔记(11) - 列表生成式
- python网络编程学习笔记(8):XML生成与解析(DOM、ElementTree)
- python网络编程学习笔记:XML生成与解析(DOM、ElementTree)
- python网络编程学习笔记(八):XML生成与解析(DOM、ElementTree)
- Python学习笔记(四)—生成随机数
- 【Python学习笔记】-生成验证码图片
- 使用python-pygame包生成一个艺术照片-学习笔记13