Python 入門指南 5.0
exercise4302.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
33
34
35 | # 從 Brython 引入 document 並以 doc 為別名
from browser import document as doc
# 從 Brython 引入 window
from browser import window
# 回傳歡迎字串
def hello_string(n):
hello = ["歡", "歡迎", "歡迎光", "歡迎光臨"]
return hello[n]
# 歡迎訊息索引值
i = 0
# 顯示歡迎動畫
def animate_hello():
doc["display"].style.textAlign = "center"
doc["display"].style.backgroundColor = "#222"
doc["display"].style.color = "white"
doc["display"].style.fontSize = "2.5em"
def show_string():
global i
doc["display"].text = hello_string(i)
if i < 3:
i += 1
else:
i = 0
window.setInterval(show_string, 700)
animate_hello()
# 檔名: exercise4302.py
# 說明:《Python入門指南》的練習
# 網站: http://kaiching.org
# 作者: 張凱慶
# 時間: 2023 年 12 月
|