0

Am starting learning python, when i want erase all the result in shell, I need to close the shell, can I do this with some command or control keyboard?

martineau
  • 119,623
  • 25
  • 170
  • 301
kevin vargas
  • 19
  • 1
  • 3

2 Answers2

3

Try this code: import os

def clear():
    name = os.name

    if name == 'nt':  # windows
        os.system('cls')
    else:  # mac and linux
        os.system('clear')
        
 
Qiu YU
  • 517
  • 4
  • 20
isaacnia
  • 46
  • 3
0

You can use os.system('clear') to talk to the operating system, and ask the system to run the clear command. Of course you have to add import os at the beginning.

xszym
  • 928
  • 1
  • 5
  • 11