The error is not in the file, but in the line file_name . You need to avoid backslashes in your file name; use the raw string:
open(r'C:\Users\user\Documents\w-game\run\map1.txt')
because \Uhhhhhhhh is the unicode exit code for a character outside of BMP.
You can also double slashes:
open('C:\\Users\\user\\Documents\\w-game\\run\\map1.txt')
or use slashes:
open('C:/Users/user/Documents/w-game/run/map1.txt')
Demo:
>>> print('C:\Users') File "<stdin>", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape >>> print(r'C:\Users') C:\Users >>> print('C:\\Users') C:\Users >>> print('C:/Users') C:/Users
Martijn pieters
source share