python barcode_python生成128条形码(code128)详解

本文介绍如何使用Python的hubarcode库、pygame和PIL库生成Code128条形码,并结合中文文字合成新的条码图片。示例代码展示了生成条形码、条码描述及两者合成的步骤。
摘要由CSDN通过智能技术生成

#-*- encoding: utf-8 -*-

import logging

import sys

import os

import pygame

from pygame.locals import *

from hubarcode.code128 import Code128Encoder

from PIL import Image,ImageDraw,ImageFont

#logging.getLogger("code128").setLevel(logging.DEBUG)

#logging.getLogger("code128").addHandler(logging.StreamHandler(sys.stdout))

#12-80 10-80 10-60 12-60 10-70 12-70 10-70

'''

使用huBarcode,pygame和PIL生成条形码

'''

if __name__ == "__main__":

#1 生成条形码

text = "068080835AD000D10701014111".upper()

encoder = Code128Encoder(text,options={"ttf_font":"C:/Windows/Fonts/SimHei.ttf","ttf_fontsize":12,

"bottom_border":15,"height":70,"label_border":2})

encoder.save("test.png",bar_width&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值