Home > Software design >  How to open a file with an editor via terminal
How to open a file with an editor via terminal

Time:03-20

The goal is: opening a .py file with an IDE(ex.VS Code) with using terminal, and using the code in python os.

os.system("python3 test.py")

but this code RUNS the file, I want to open it with an editor.

CodePudding user response:

Most editors lets you open files by putting the name of the editor behind the file. For example, in a terminal, you can write code to open VSCode

code test.py

So with the os lib, you could use

os.system("code test.py")

CodePudding user response:

Try below command:

os.system("vi test.py")

OR

os.system("cat test.py")

OR

os.system("vim test.py")

OR

os.system("nano test.py")
  • Related