python简单的表白代码

python
import time def confession(): print("亲爱的XXX:") time.sleep(2) print("我一直想对你说...") time.sleep(2) print("我喜欢你!") time.sleep(2) print("愿意和我一起共度余生吗?") time.sleep(2) print("爱你的YYY") confession()

你可以将"XXX"和"YYY"替换为你和你心爱的人的名字。这个程序会按照你设置的时间间隔逐句输出表白内容。

python
import time def confession(): your_name = input("请输入你的名字:") crush_name = input("请输入心爱的人的名字:") print(f"亲爱的{crush_name}:") time.sleep(2) print("我一直想对你说...") time.sleep(2) print(f"我喜欢你,{crush_name}!") time.sleep(2) print("愿意和我一起共度余生吗?") time.sleep(2) print(f"爱你的{your_name}") confession()

这个版本会要求用户输入他们的名字和心爱的人的名字,然后按照相同的方式输出表白内容。