sydomain

思绪来的快,去的也快,偶尔在这里停留。

python绑定cpu序列号配合到期时间

import sys
from datetime import datetime, timedelta
import tkinter as tk
from tkinter import messagebox

def check_expiry(expiry_date, cpu_serial):
    current_date = datetime.now()
    expiry_date = datetime.strptime(expiry_date, "%Y-%m-%d %H:%M")

    if current_date < expiry_date:
        # 检查CPU序列号是否匹配
        if cpu_serial == "BFEBFBFF000306A9":
            remaining_time = expiry_date - current_date
            remaining_days = remaining_time.days
            remaining_hours = remaining_time.seconds // 3600
            remaining_minutes = (remaining_time.seconds % 3600) // 60
            messagebox.showinfo("到期提醒", f"还有 {remaining_days} 天 {remaining_hours} 小时 {remaining_minutes} 分钟到期")
        else:
            messagebox.showwarning("到期提醒", "设备未授权,请联系客服")
            sys.exit(1)
    elif current_date == expiry_date:
        messagebox.showinfo("到期提醒", "今天到期")
    else:
        messagebox.showwarning("到期提醒", "已过期,请联系客服充值\n wx:13888888888")
        sys.exit(1)  # 使用非零状态码表示程序异常退出

expiry_date = "2024-02-08 12:30"
cpu_serial = "BFEBFBFF000306A9"
check_expiry(expiry_date, cpu_serial)
cpu_serial=替换成你指定的序列号


Powered By sydomain

Copyright Your WebSite.Some Rights Reserved.