I need to open an excel file with os. I know it's pretty easy as;
import os
os.system("start EXCEL.EXE file.xlsx")
However, name of my file varies depending on my py file.
I defined a variable called "fileopenerfullname" and it is the name of the file i want to open.
But how can i insert "fileopenerfullname" variable in os.SYSTEM("start EXCEL ......")?
I tried very much including
os.system("start EXCEL.EXE fileopenerfullname")
Does not work.
I will be glad if anyone can help.
CodePudding user response:
Use formatted strings:
os.system(f"start EXCEL.EXE {fileopenerfullname}")
but don't forget your fileopenerfullname should include the extension .xlsx at the end.
CodePudding user response:
try use:
os.system("start excel excel_file_path")
