skip to Main Content

my vs code python terminal wont refresh itself automatically and to run the same code again i have to close the terminal and run the program again.
is there any extension or shortcut which may help me?

2

Answers


  1. You can append the following lines to the end of your code.

    import os
    os.system('clear')
    

    This runs the clear command on the terminal and clears your terminal screen, which seems to be what your expectation is.

    Login or Signup to reply.
  2. Make sure to import the module os

    Place at the top of the script the import statement

    import os
    

    Then, place this line of code where you want the terminal clearing (clear) to happen

    os.system('tput reset')
    

    PS: you can also use os.system('clear') as suggested in the previous answer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search