In the following programs you will learn that how to open specific computer file by using specific application.
import os #opening 'MyTxtFile.txt' using NotePad.
print("Opening MyTxtFile text file using notepad application")
osCommandString = "notepad.exe C://MyTxtFile.txt"
os.system(osCommandString)
import subprocess as sp
print("Opening MyTxtFile text file using notepad application")
programName = "notepad.exe" #opening 'MyTxtFile.txt'
fileName = "C://MyTxtFile.txt" #using Notepad.
sp.Popen([programName, fileName])
import subprocess
print("Opening MyTxtFile text file using notepad application")
subprocess.call(["notepad.exe", "C://MyTxtFile.txt"])
import subprocess
print("Opening application list to select application to open MyTxtFile text file")
subprocess.call(["cmd.exe", "/c", "C://MyTxtFile.txt"])