So I’m having problems opening a file for reading, and so I decided to just try an os.isfile assert:
from Android_API_Parser import Android_API_Parser
import os.path
assert os.path.isfile("D:\Work\Python Workspace\Android_API_Parser\test.txt")
tester = Android_API_Parser()
tester.setFile("test.txt")
tester.parse()
It’s failing the assert:
Traceback (most recent call last):
File "D:\Work\Python Workspace\Android_API_Parser\src\Android_API_Tester.py", line
9, in <module>
assert os.path.isfile("D:\Work\Python Workspace\Android_API_Parser\test.txt")
AssertionError
I have opened the path to the file I’m trying to open and pasted it below:
D:\Work\Python Workspace\Android_API_Parser\test.txt
Any ideas as to why it’s even failing the assert? Unless I’m really tired, the file is clearly located there. I even tried both with “/” and “\”, even with escape characters included.
In a string literal, you must escape backslashes with another backslash, use a raw string, or use forward slashes. Otherwise,
"\t"becomes a string that just contains the tab character.Try any of:
The file may also not be a regular file. Use
os.path.existsto see if it exists.You may also have insufficient privileges to see the file, or the file name you expect may be localized. To debug this, run: