Outline
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
When reading pickle file, the above error is reported
Pickle file path is copied directly, no problem
So was confused and finally found a solution on the Internet, so he made a record:
Solution
The picture above shows the error message and the file path
It seems that there is no problem, but the problem still appears in the path
Because in Windows system, the “\” in the path will be escaped
For example, if you configure a path: D:// source <XXX/a.txt, the system will escape the “ ” to a tab key, so that the file path is wrong
The correct path should be:
The first way to write: D:\\source\\\t\\xxx\\\a.txt
Second way to write: r "D:\source\t\xxx\\a.txt"
The third way to write: D:/source/t/xxx\a.txt # Path writing in Linux
the third writing method is recommended because it is common in windows and Linux
Similar Posts:
- Python Files Error: SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: tr
- Python:SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in pos…
- [Solved] Python error: EOFError: Ran out of input
- XML parsing & special character error
- “Failed to load ldlinux. C32” appears during Ubuntu installation
- Python TypeError: file must have ‘read’ and ‘readline’ attributes
- Dill: solve the problem of Python’s “attributeerror: can’t pickle local object” and unable to pickle lambda function
- [How to Solve] SSL handshake failed: SSL error
- Solution to fatal error in launcher: unable to create process using ‘”‘In PIP installation
- Solve the problem of ADB: command not found on MAC