python字符转换条码


import barcode
from barcode.writer import ImageWriter
import os

from PIL import Image
def barcode_to_png(barcode_type,text_str,filename): 
      EAN = barcode.get_barcode_class(barcode_type) #设置生成一维码的类型 
      ean = EAN(text_str, writer=ImageWriter())   
      ean.save(filename)

#条码类型code128,转换内容123456,文件名称name.png
barcode_to_png('code128','123456',"name")

你可能感兴趣的:(python,python,开发语言)