【发布时间】:2016-11-12 17:25:48
【问题描述】:
import time
listy = ['timer','stopwatch']
def intro():
print("This is a program which contains useful tools")
print(listy)
def timer():
x = int(input("How long Seconds ?"))
while x > 0:
print(x)
time.sleep(1)
x -= 1
def stopwatch():
verif = input("Do you want to start y/n \n")
if verif == 'y':
x = 0
while True:
print(x, end = "\b"*5)
time.sleep(1)
x += 1
def main():
intro()
decider = input("Which Program?")
if decider.lower() == 'timer':
timer()
elif decider.lower() == 'stopwatch':
stopwatch()
main()
在这段代码中,我不知道为什么 \b 转义序列不能在 cmd 或空闲状态下工作,谁能解释为什么?是不是因为逻辑错误?
【问题讨论】:
-
如果您将其替换为另一个(可打印的!)字符,您是否看到它出现在您期望的位置?如果你不这样做,那就是逻辑错误。
-
是的,但我希望它只计入同一行
-
"是的" = "是的,我看到它出现了"?这有关系吗? stackoverflow.com/q/9667462/2564301
标签: python cmd python-idle