Home python Clear python console in PyCharm

Clear python console in PyCharm

Author

Date

Category

I am writing a simple reinforcement learning algorithm, in which there is a simple animation, by means of output to the console. So, to show a new frame of animation, I need to somehow clear this console. Now I’m using print (100 * '\ n') , but it doesn’t look very nice due to the console scrolling. I use PyCharm IDE if it matters. Tried os.system (‘cls’) and print (‘\ k’) – doesn’t work. Is it possible to somehow clear the console to re-output a new frame of animation to it?

P.S. It is worth adding: frame is a square matrix of size n, each element of which is a separate symbol: = if the cell is empty, A – if there is an agent in the cell, E – if there is an enemy in the cell. The matrix is ​​updated and a new frame is displayed. Now n = 7. The total number of frames cannot be known in advance.


Answer 1, authority 100%

In general, the os.system ('cls') method works for the console, which breaks when outputting inside PyCharm. On the other hand, right inside PyCharm there is a terminal that this function works with.

UPD: PyCharm technical support advised to enable terminal emulation in the output console (this is done in Run | Edit Configurations). With emulation enabled, os.system ('cls') works fine in the output console as well.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions