使用python创建标准条码。不需要外部模块(包括可选的PIL支持)。

tiqetsbarcode的Python项目详细描述


维瓦库迪 是pyBarcode的叉 项目。

这个库提供了一种简单的方法,只使用 python标准库。创建为SVG对象的条形码。

https://github.com/kxepal/viivakoodi/issues/报告错误

要求

  • Setuptools/distribute for installation (new in version 0.7beta4)
  • Python 2.6 or above (including Python 3.x)
  • On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
  • Program to open SVG objects (your browser should do it)
  • Optional: PIL to render barcodes as images (PNG, JPG, …)

安装

确保安装了setuptools/distribute。

将下载的文件cd解压到viivakoodi目录并运行 python setup.py安装。或者复制条形码目录 你的Python。

最好的方法是使用pip:pip install viivakoodi

提供的条形码

EAN-8、EAN-13、UPC-A、JAN、ISBN-10、ISBN-13、ISSN、代码39、代码128、PZN

待办事项

  • Add documentation
  • Add more codes
  • Improve Python 3 support
  • Add simple GUI

用法

交互式:

>>> import barcode
>>> barcode.PROVIDED_BARCODES
[u'code39', u'code128', u'ean', u'ean13', u'ean8', u'gs1', u'gtin',
 u'isbn', u'isbn10', u'isbn13', u'issn', u'jan', u'pzn', u'upc', u'upca']
>>> EAN = barcode.get_barcode_class('ean13')
>>> EAN
<class 'barcode.ean.EuropeanArticleNumber13'>
>>> ean = EAN(u'5901234123457')
>>> ean
<barcode.ean.EuropeanArticleNumber13 object at 0x00BE98F0>
>>> fullname = ean.save('ean13_barcode')
>>> fullname
u'ean13_barcode.svg'
# Example with PNG
>>> from barcode.writer import ImageWriter
>>> ean = EAN(u'5901234123457', writer=ImageWriter())
>>> fullname = ean.save('ean13_barcode')
u'ean13_barcode.png'
# New in v0.4.2
>>> from StringIO import StringIO
>>> fp = StringIO()
>>> ean.write(fp)
# or
>>> f = open('/my/new/file', 'wb')
>>> ean.write(f) # PIL (ImageWriter) produces RAW format here
# New in v0.5.0
>>> from barcode import generate
>>> name = generate('EAN13', u'5901234123457', output='barcode_svg')
>>> name
u'barcode_svg.svg'
# with file like object
>>> fp = StringIO()
>>> generate('EAN13', u'5901234123457', writer=ImageWriter(), output=fp)
>>>

现在在图形应用程序中或在浏览器中打开EAN13_u条码。[SVG PNG] 并查看创建的条形码。就这样。

命令行:

$ pybarcode{2,3} create "My Text" outfile
New barcode saved as outfile.svg.
$ pybarcode{2,3} create -t png "My Text" outfile
New barcode saved as outfile.png.

Try `pybarcode -h` for help.

更改日志

v0.8:Code 128 added. Data for charsets and bars moved to subpackage barcode.charsets.
v0.7:Fixed some issues with fontsize and fontalignment. Added Python 3 support. It’s not well tested yet, but the tests run without errors with Python 3.3. Commandline script added.
v0.6:Changed save and write methods to take the options as a dict not as keyword arguments (fix this in your code). Added option to left align the text under the barcode. Fixed bug with EAN13 generation.
v0.5.0:Added new generate function to do all generation in one step. Moved writer from a subpackage to a module (this breaks some existing code). UPC is now rendered as real UPC, not as EAN13 with the leading “0”.
v0.4.3:Fixed bug in new write method (related to PIL) and updated docs.
v0.4.2:Added write method to support file like objects as target.
v0.4.1:Bugfix release. Removed redundancy in input validation. EAN8 was broken. It now works as expected.
v0.4:Removed **options from writers __init__ method. These options never had effect. They were always overwritten by default_options. New config option available: text_distance (the distance between barcode and text).
v0.4b2:Basic documentation included. The barcode object now has a new attribute called raw to have the rendered output without saving to disk.
v0.4b1:Support for rendering barcodes as images is implemented. PIL is required to use it.
v0.3:Compression for SVG output now works.
v0.3b1:Writer API has changed for simple adding new (own) writers. SVG output is now generated with xml.dom module instead of stringformatting (makes it more robust).
v0.2.1:API of render changed. Now render takes keyword arguments instead of a dict.
v0.2:More tests added.
v0.1:First release.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将字符串转换为自定义对象   java如何从socket方法获取数据?   Java中的soap读取回车和新行   java在单击时替换图像   java推荐的使用RXJava执行异步任务的方法   java MySql连接器JDBC驱动程序不支持连接池吗?   java将活动堆栈清理到顶部   java计数用户输入的数量   java从webservice下载大文件导致应用程序性能问题   JavaLocalDate。EPOCH不可用   java如何在使用Selenium等待一定时间后,在页面无法加载(get(url))时自动刷新页面   java Calendar setLenient方法不允许检查年份字段的健全性   java Eclipse和intelliJ 安卓 SDK问题   java为什么我可以在没有super关键字的情况下调用父方法?   java iText的PDF格式不好