繁体   English   中英

Python中的转义序列不适用于CMD

[英]Escape Sequences in Python Not Working in CMD

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或空闲状态下工作,有人可以解释为什么吗? 是因为逻辑错误吗?

可能需要冲洗。 怎么样...

print("{0}{1}".format("\b"*5, x), end="", flush=True)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM