代码只能防止精度不高,而是大区域识别二维码的’机器人‘抢码
大佬们多多指教
import qrcode
import tkinter as tk
import time
from PIL import ImageTk
import random
def generate_qr_code(data, box_size=10):
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=box_size, border=4)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
return img
def display_qr_code(data, label, box_size=10):
image = generate_qr_code(data, box_size)
photo = ImageTk.PhotoImage(image)
label.configure(image=photo)
label.image = photo
if __name__ == '__main__':
root = tk.Tk()
root.title('QR Code Generator')
label = tk.Label(root)
label.pack()
while True:
data = "https://user.mihoyo.com/qr_code_in_game.html?app_id=4&app_name=%E5%8E%9F%E7%A5%9E&bbs=true&biz_key=hk4e_cn&expire=1718366329&ticket=" + ''.join(
random.choice('0123456789abcdef') for i in range(24))
display_qr_code(data, label, box_size=2) # 设置box_size为20来改变QR代码的大小
root.update()
time.sleep(1)
root.mainloop()