Python 入門指南 5.0
exercise4303.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # 從 Brython 引入 document 並以 doc 為別名 from browser import document as doc # 從 Brython 引入 window from browser import window # 從 datetime 引入 datetime from datetime import datetime # 設定現在時間 doc["display"].style.textAlign = "center" doc["display"].style.backgroundColor = "#222" doc["display"].style.color = "white" doc["display"].style.fontSize = "2.5em" now = datetime.now() if now.hour < 10: hour = "0" + str(now.hour) else: hour = str(now.hour) if now.minute < 10: minute = "0" + str(now.minute) else: minute = str(now.minute) if now.second < 10: second = "0" + str(now.second) else: second = str(now.second) doc["display"].text = f"{hour}:{minute}:{second}" # 檔名: exercise4303.py # 說明:《Python入門指南》的練習 # 網站: http://kaiching.org # 作者: 張凱慶 # 時間: 2023 年 12 月 |