34 lines
815 B
Python
34 lines
815 B
Python
# -*- coding: utf-8 -*-
|
|
# @Version: Python 3.9
|
|
# @Time : 2022/5/11 9:57
|
|
# @Author : chenyinhua
|
|
# @File : lover.py
|
|
# @Software: PyCharm
|
|
# @Desc: 使用Python打印爱心图案
|
|
|
|
|
|
import time
|
|
|
|
|
|
def lover():
|
|
target = "♥"
|
|
for char in target.split():
|
|
all_char = []
|
|
for y in range(12, -12, -1):
|
|
lst = []
|
|
lst_con = ""
|
|
for x in range(-30, 30):
|
|
formula = ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (x * 0.05) ** 2 * (y * 0.1) ** 3
|
|
if formula <= 0:
|
|
lst_con += char[x % len(char)]
|
|
else:
|
|
lst_con += " "
|
|
lst.append(lst_con)
|
|
all_char += lst
|
|
time.sleep(1)
|
|
return "\n".join(all_char)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print(lover())
|