WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
558 stars 123 forks source link

Would you please help us fix bar code letter question (EX:A300113111)? #96

Open yipingliu0402 opened 3 years ago

yipingliu0402 commented 3 years ago

Would you please help us fix bar code letter question (EX:A300113111)?

import barcode from barcode.writer import ImageWriter

string='A300113111' ean = barcode.get('ean13',string, writer=ImageWriter())

error: raise IllegalCharacterError("EAN code can only contain numbers.") barcode.errors.IllegalCharacterError: EAN code can only contain numbers.

lieryan commented 3 years ago

As the error message says EAN13 barcodes can only contain decimal digits, the standard doesn't specify any mechanism for encoding non-digits symbols. If you want to encode letters, you need to use a different barcode format.

If you have a choice of format, try Code128 or Code39 if you need a 1-dimensional barcodes that can contain letters.