quarta-feira, junho 24, 2020

How to clear screen in python?

How to clear screen in python?


https://www.geeksforgeeks.org/clear-screen-python/

# import only system from os
from os import system, name

# import sleep to show output for some time period
from time import sleep

# define our clear function
def clear():

    # for windows
    if name == 'nt':
        _ = system('cls')

    # for mac and linux(here, os.name is 'posix')
    else:
        _ = system('clear')

# print out some text
print('hello geeks\n'*10)

# sleep for 2 seconds after printing output
sleep(2)

# now call function we defined above
clear()

Sem comentários: