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

reBarcode的Python项目详细描述


叉子pyBarcode 项目。

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

要求

  • 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、EAN-14、UPC-A、JAN、ISBN-10、ISBN-13、ISSN、代码39、代码128、PZN

待办事项

  • Add documentation
  • Improve Python 3 support

用法

交互式:

>>> 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 io import BytesIO
>>> fp = BytesIO()
>>> 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.1:First release.

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

推荐PyPI第三方库


热门话题
javajavax。艾尔。PropertyNotFoundException:   java为什么通过TCP发送的文件比它本身包含的文件包含更多的数据?   java为什么字符开关/案例不起作用?   php到java连接器,在哪里可以找到好的连接器   需要帮助Java简单规则形状面积计算器和if语句吗   macos如何从newstyle Oracle Java OSX捆绑包结构启动帮助页?   java既然所有的类都扩展对象,而对象是一个类,那么对象如何扩展对象呢?   java从JavaPairdd<String,Tuple2<Integer,Integer>>转换为JavaPairdd<String,Integer>   java微调器值未从一个活动传递到另一个活动   参数化类型的java数组   java不提供类。getCanonicalName是否存在性能问题?   java输入键JTextField   为什么我不能在java中调用nextLine()方法两次?   JTextPane中的java JProgressBar   java如何获取Crudepository实例?   用于提取几个<div>标记的java正则表达式   java如何使用JUnit Testrunner生成html图像   Go中Java静态属性的等价性