Skip to content Skip to sidebar Skip to footer

Python - Ctrl L Does Not Work

Attempting to use Ctrl+L for clearing Power Sheel in Python 2.7.8 I get no response. Is there any problem in Windows 10?

Solution 1:

Ctrl+L only works on Linux/OS X terminals. It does not work on Windows. To clear the screen on Windows you could do the following:

import osos.system('cls')

Solution 2:

To extend Kredns answer to Linux/OS X terminals as well:

import osos.system('clear')

Solution 3:

I like Kredns's answer, however, you have to type all of that every time. I made a module/function. Okay, I am using Python 3.7.3, but similar answer for Python 2.

def cls():
    import os
    os.system('cls')
    return

Save this as a script and import cls or whatever you want to call it. Import that (e.g. on python start up). So if you're in the correct directory:

from cls import cls

Then call it with cls() whenever you want to clear the screen.

cls()

Solution 4:

IdleX extension of IDLE has the functionality you are looking for. Try installing from here http://idlex.sourceforge.net/ OR https://pypi.org/project/idlex/

pressing CTRL-L, works in the intutive way (clear the console and take you to the top with a prompt, and doesn't clear the variables and definitions you have defined yet)

Post a Comment for "Python - Ctrl L Does Not Work"