跳动的爱心python代码
时间: 2023-07-23 17:35:59 浏览: 115
python非常炫酷的跳动爱心代码
以下是跳动的爱心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()
```
运行代码会输出一个跳动的爱心动画。
阅读全文