+ 2

How can i clear screen in python ?

22nd Aug 2016, 3:15 PM
MeoQ
MeoQ - avatar
8 Respostas
+ 5
This was my question too and @Dimitriy is the only one who answered it correctly. Thank you buddy.
23rd Aug 2016, 4:52 AM
Alireza M
Alireza M - avatar
+ 4
if you mean you need to "flush" the console output, you may need to use 'os' module to perform system operations like that. import os #then, under Linux, call os.system('clear') #under windows call os.system('cls') you wrote that you run python under Android, and since Android is Linux-based, 'clear' may work, but it needs to be tested.
22nd Aug 2016, 7:48 PM
Demeth
Demeth - avatar
+ 1
Yes off course... Just follow these instructions :- →From os import system. →Define a function. →Make a system call with ‘clear’ in Linux and ‘cls’ in Windows as an argument. →Store the returned value in an underscore or whatever variable you want (an underscore is used because python shell always stores its last output in an underscore). →Call the function we defined. • You can see the implementation also taking one example... from os import system, name from time import sleep def clear(): if name == 'nt': _ = system('cls') else: _ = system('clear') print('Please upvote my answer if satisfied... \U0001F60A \n\t\t\U0001F60C \n'*25) sleep(5) clear() print("Follow me ...\n \t\t\t https://www.sololearn.com/Profile/18746952/?ref=app") print("Thanks")
3rd Oct 2021, 7:31 AM
Neeraj Kumar
Neeraj Kumar - avatar
0
Try using ctrl+l on the terminal.
22nd Aug 2016, 3:23 PM
Surya Deep Mishra
Surya Deep Mishra - avatar
0
but , i using qpython on Android beacouse my computer is broken , sorry i dont good in english beacouse i from Poland.
22nd Aug 2016, 4:14 PM
MeoQ
MeoQ - avatar
0
U can use other IDE, like PyCharm or Sublime with syntax highlighting plugin. With ever new run ur program screen will be cleaned. Good luck) P. S. Try push back button and type new code again.
22nd Aug 2016, 5:47 PM
John Doe
John Doe - avatar
0
I am using Q Python 3 I wants got the result from searching how to clear screen in python. But now when I am searching I am just getting for Windows and Linux
26th Dec 2017, 3:02 PM
Arup Datta
Arup Datta - avatar
0
Is there another way avaiable ? os.system('clear') doesnt work. Even ctrl+L, clear, cls it also didn't work.
26th Sep 2019, 8:47 PM
Mysterious Noob
Mysterious Noob - avatar