1
0
mirror of https://github.com/x-hw/amazing-qr.git synced 2025-07-11 01:10:17 +02:00
Files
amazing-qr/myqrcode.py

28 lines
634 B
Python
Raw Normal View History

2016-08-27 16:29:56 +08:00
# -*- coding: utf-8 -*-
2016-08-28 16:50:37 +08:00
import draw, ECC, data, structure
2016-08-27 16:29:56 +08:00
# ecl: Error Correction Level(L,M,Q,H)
def get_qrcode(ecl, str):
try:
2016-08-28 16:50:37 +08:00
# Data Coding
ver, data_codewords = data.encode(ecl, str)
# Error Correction Coding
ecc = ECC.encode(ver, ecl, data_codewords)
# Structure final bits
final_bits = structure.structure_final_bits(ver, ecl, data_codewords, ecc)
# Get the QR Matrix
2016-08-27 16:29:56 +08:00
except UnicodeEncodeError:
print('Error input!!')
if __name__ == '__main__':
# test:
2016-08-28 16:50:37 +08:00
str = 'HELLO WORLD'
2016-08-27 16:29:56 +08:00
str2 = '💩'
2016-08-28 16:50:37 +08:00
get_qrcode('M',str)