How to create a barcode in python
In this projects we are going to create a barcode with the help of python.
You can also see How to Convert PDF files to Doc file, How to create URL Shortner with Python .
You can use python-barcode to generate different types of objects. First install the barcode:
pip install python-barcode
Below, we are going to create an ISBN13 barcode. Please note that this module supports many other types of barcodes. We are going to generate a PNG image of the barcode. We will use the pillow module to view the image. You can install pillows by running:
pip install pillow
Pass a 12-digit number as a string.
from barcode import ISBN13
from barcode.writer import ImageWriter
from PIL import Image
num = '979117528719'
# saving image as png
bar_code = ISBN13(num, writer=ImageWriter())
# save image
bar_code.save('bar_code')
#read the image using pillow
img = Image.open("bar_code.png")
img.show()
Output:

