In a string literal, '\t' represents a tab character (ordinal 9). Windows filenames cannot contain control characters [1], i.e. ordinals 1-31. For path literals I recommend using forward slashes and normalizing via os.path.normpath, e.g. filepath = os.path.normpath('C:/Users/mavri/Desktop/proba/testni.wav').
FYI, the way exists() is written handles any OSError as False:
def exists(path):
try:
os.stat(path)
except OSError:
return False
return True
In your case, stat() fails with ERROR_INVALID_NAME (123):
>>> os.stat('\testni.wav')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [WinError 123] The filename, directory name, or volume label
syntax is incorrect: '\testni.wav'
[1]: https://msdn.microsoft.com/en-us/library/aa365247#naming_conventions |