跳动的爱心Python代码
时间: 2023-07-23 15:08:44 浏览: 106
跳动爱心代码.py
以下是跳动的爱心Python代码:
```
import time
def heart_animation():
heart = '\033[91m' + " ♥♥ " + '\033[0m'
empty_heart = " "
heart_list = [empty_heart, empty_heart, empty_heart, empty_heart, empty_heart, empty_heart, heart, heart, empty_heart]
while True:
for i in range(9):
time.sleep(0.1)
print(heart_list[i])
heart_list.insert(0, heart_list.pop())
if i == 8:
heart_list = [empty_heart, empty_heart, empty_heart, empty_heart, empty_heart, empty_heart, heart, heart, empty_heart]
heart_animation()
```
运行代码会输出一个跳动的爱心动画。
阅读全文