"""
幽默的随机选择.py
random.choice命令演示程序
"""
import random
from sprites import *
screen = Screen()
screen.setup(640,780)
cats = []
for i in range(10):
x = -120
y = 300 - i * 70
cats.append(Sprite(2,pos=(x,y)))
b = Sprite(6)
b.rotatemode(1)
b.right(180)
b.bk(100)
b.wait(1)
b.say('random.choice命令演示程序',delay=4)
b.say('现在开始')
b.say('想去抓老鼠的站出来!')
screen.delay(2)
被选择的猫 = random.choice(cats)
for cat in cats:
if cat == 被选择的猫:continue
cat.speed(1)
cat.bk(100)
cat.wait(1)
被选择的猫.say('咦,其它猫呢?')
b.say('你站出来了,就你了!')
被选择的猫.say('蝶妹,我冤枉啊')
b.say('猫哥,你应该感到幸福!')
screen.mainloop()
-
- 2025 年 10 月
- 2025 年 9 月
- 2025 年 6 月
- 2025 年 5 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2023 年 11 月
- 2023 年 9 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 2 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 8 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 5 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 7 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2018 年 3 月
- 2018 年 1 月
- 2017 年 9 月
- 2017 年 5 月
- 2017 年 1 月

