我对基本的简单python有一个问题。所以我在做一个记忆游戏,我想显示对象,在延迟5秒后,让文本消失
import time
print("Welcome to the memory game.")
print("Choose difficulty level :")
print("1. Easy")
print("2. Medium")
print("3. Hard")
print("4. Very Hard")
x = input("press '1' for easy, '2' for medium, '3' for hard and '4' for very hard : ")
if x == '1' :
print("You chose level 1, easy.")
print("I will give you 3 objects and you have to type then in the correct order to gain points.")
print("Not cAsE SeNSitIvE")
obj = print("Ship, Money, Python")
time.sleep(5)
ez = input().upper
if ez == 'Ship, Money, Python' or ez == 'ship,money,python' or ez == 'Ship,Money,Python' or ez == 'ship, money, python' :
print("Correct")
else :
print("Wrong")
print("The answer was : Ship, Money, Python")
这是代码的一部分。请帮帮我😅 我想隐藏文本
obj = print("Ship, Money, Python")
延迟5秒后
编辑:简化您的检查以打印输入的正确性
试试这个:
以
"\r"
结尾会导致下一个输出从上一行的开头开始。然后可以用适当数量的空格(" " * len(text)
)替换输出这里有一个有效的解决方案。它使用
\r
返回行的开头,并使用\033[K
清除行:相关问题 更多 >
编程相关推荐