简体   繁体   中英

How to clear 'run' window in PYCHARM using python code when needed

I want to clear the ' run ' window using python code every time when a loop runs to clear certain pieces of text.

Could someone please help.??

You can use os.system('clear') for mac and linux and os.system('cls') for windows.

For example:

import os
for i in range(100):
   print(i)
   os.system('clear')

If you get TERM environment variable not set warning, click Open 'Edit run/debug configurations' dialog which is on the left of the run button and check the checkbox at Edit Configurations -> Executions -> Emulate terminal in output console .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM