I am on Windows, and none of the files exist in my directory.
I have trouble figuring out why:
fid = open('L01A.txt', 'x')
fid.write('A')
fid.close()
fid = open('L01a.txt', 'x')
fid.write('a')
fid.close()
gives me:
[Errno 17] File exists: 'L01a.txt'.
You open your file with mode 'x', which is used only to create a file. From the doc
'x', open for exclusive creation, failing if the file already exists
You should use another mode, here is a useful link to descriptions to different modes that can be useful to you
python open built-in function: difference between modes a, a+, w, w+, and r+?
Edit: Apparently your error is that you cannot create 2 files with names L01A
and L01a
with two different cases, this is windows file system is not case sensitive. You cannot create two distincts files.
If you absolutely need the case sensitive, you can enable NTFS to do so in the directory, with launching an admin powershell and execute fsutil.exe file setCaseSensitiveInfo C:\folder enable
According to this thread, you might want to enable this for all subdirectories, here is a way to do so Apply setCaseSensitiveInfo recursively to all folders and subfolders.
Thanks Lalush for the thread.