Answer the question
In order to leave comments, you need to log in
How to clear python console?
I am writing a simple reinforcement learning algorithm, which has a simple animation, through console output. So, to show a new animation frame, I need to clear this console somehow. Right now I'm using print(100*'\n') but it doesn't look very pretty due to console scrolling. I'm using PyCharm IDE if that matters. Tried os.system('cls') and print('\k') - doesn't work. Is it possible to somehow clear the console in order to re-output a new animation frame into it?
PS It is worth adding: the 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 the question
In order to leave comments, you need to log in
This is how it works on Linux:
import os
print('Hello')
input()
os.system('cls||clear')
print("Привет")
input()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question