Reputation: 3
Code:
os.startfile("C:\finished.py")
Return:
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\**x0cinished**.py'
Expectation: take C:\finished.py
What could be causing python to change my input like this?
Upvotes: 0
Views: 232
Reputation: 81614
'\f'
is a special character (see Table of escape sequences). You should make it a habit to use r
(raw strings) when working with hard-coded paths:
os.startfile(r"C:\finished.py")
Upvotes: 5
Reputation: 1677
You need to escape the "\" character. Write "C:\\finished.py" in your startfile statement.
Upvotes: 3