Alex L
Alex L

Reputation: 167

os.system('cls') doesn't clear the screen in Pycharm?

I use os.system('cls') in Pycharm to clear the screen from what has been printed before. However, when running the code, it does not clear the formerly printed stuff, and instead prints an upward arrow at the end. What can the problem be?

Upvotes: 6

Views: 12996

Answers (3)

rubStackOverflow
rubStackOverflow

Reputation: 6203

Workaround:

print('\n'*80)

Not perfect but works.

Upvotes: 0

Jonas
Jonas

Reputation: 71

If you want the terminal to emulate your OSs terminal, you have to edit the 'Run/Debug Configuration' and tick the box 'Emulate terminal in output console'.

Then os.system("cls") will clear the screen on Windows and os.system("clear") on unix

Upvotes: 7

BoarGules
BoarGules

Reputation: 16951

PyCharm's emulation of the Windows system console isn't 100%. Neither is any IDE's. Try that in IDLE or PythonWin, and you will see that it also does something other than you might expect from the Windows console.

This behaviour is by design. Bear in mind that most real-world Python interactive applications do not interact with their users via input() and print() calls.

If you want your output to behave exactly like the Windows console then send your output to the Windows console.

Upvotes: 8

Related Questions