A simple and cross-platform solution would be to use either the cls
command on Windows, or clear
on Unix systems. Used with os.system
, this makes a nice one-liner:
import os
os.system('cls' if os.name == 'nt' else 'clear')
More Related Contents:
- Execute python script while open terminal
- Sub-process in Python execute two task? [closed]
- How do I execute a program or call a system command?
- How do I print colored text to the terminal in Python?
- How to get Linux console window width in Python
- What’s the simplest way of detecting keyboard input in a script from the terminal?
- Is there go up line character? (Opposite of \n)
- Add pygame module in PyCharm IDE
- Execute terminal command from python in new terminal window?
- How to terminate process from Python using pid?
- Dynamic terminal printing with python
- Python Script execute commands in Terminal [duplicate]
- Why is the apt-get function not working in the terminal on Mac OS X v10.9 (Mavericks)?
- How to run Python script on terminal?
- Make python3 as my default python on Mac
- Python Sound (“Bell”)
- input(): “NameError: name ‘n’ is not defined” [duplicate]
- How to embed a terminal in a Tkinter application?
- How to fix column calculation in Python readline if using color prompt
- Import module works in terminal but not in IDLE
- How do I detect whether sys.stdout is attached to terminal or not? [duplicate]
- Why doesn’t print output show up immediately in the terminal when there is no newline at the end?
- python: unicode in Windows terminal, encoding used?
- Switch between python 2.7 and python 3.5 on Mac OS X
- How to Print “Pretty” String Output in Python
- Python module to enable ANSI colors for stdout on Windows?
- bash: Python import – Command not found for pandas
- How can I fix the “zsh: command not found: python” error? (macOS Monterey 12.3, Python 3.10, Atom IDE, and atom-python-run 0.9.7)
- add column to SQLAlchemy Table
- Execute a command on Remote Machine in Python