Py学习  »  Python

我用python制作时钟时出错了

David • 2 年前 • 522 次点击  
from tkinter import *
from tkinter.ttk import *

from time import strftime

root = Tk()
root.title('Clock')

def time():
    string = strftime('%H:%M:%S %P')
    label.config(text=string)
    label.after(1000, time)

label = Label(root, font=("ds-digital", 80), background="black", foreground="cyan")
label.pack(anchor='center')
time()

mainloop()

我犯了这个错误

File "c:\Users\david\OneDrive\Desktop\practice projects\clock.py", line 16, in <module>
    time()
  File "c:\Users\david\OneDrive\Desktop\practice projects\clock.py", line 10, in time
    string = strftime('%H:%M:%S %P')
ValueError: Invalid format string
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/130378
 
522 次点击  
文章 [ 1 ]  |  最新文章 2 年前