[Python] Why can't I clear the console? [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    I've tried every way to clear the console in Python, but nothing seems to work.

    I've tried:

    os.system('cls')
    os.system('clear')
    os.system('cls' if os.name == 'nt' else 'clear')
    subprocess.run('cls' if os.name == 'nt' else 'clear', shell=True)


    None of them result in an error, but when I use them nothing happens, it's like the line of code isn't even there.

    My code:

    import time

    number = 10
    while True:
    number = round(number * 1.1)
    α = round(number ** 0.03, 2)
    print(f"Coins: {number}\nα: {α}")
    time.sleep(0.1)


    I want to clear the console every time right before it prints.

    The difference between this and other questions like this is that none of those other methods from that question work

    Continue reading...

Compartilhe esta Página