⏰ Python简易时钟

📋 功能说明
  • Tkinter GUI时钟界面
  • 实时显示当前时间
  • 数字时钟显示
💻 源代码
import tkinter as tk
import time

class Clock:
    def __init__(self):
        self.window = tk.Tk()
        self.window.title("时钟")
        self.window.geometry("300x150")
        
        self.label = tk.Label(self.window, font=("Arial", 48, "bold"),
                             background="#2c3e50", foreground="white")
        self.label.pack(expand=True, fill="both")
        
        self.update_time()
        self.window.mainloop()
        
    def update_time(self):
        current_time = time.strftime("%H:%M:%S")
        self.label.config(text=current_time)
        self.window.after(1000, self.update_time)

if __name__ == '__main__':
    Clock()
📦 运行环境
pip install tkinter (内置)
技术特点
  • ✅ Tkinter内置库
  • ✅ 每秒自动刷新
  • ✅ 居中显示