Error reporting: syntax error: (Unicode error) ‘Unicode scape’ codec can’t decode bytes in position 2-3: tr
For example, in the file, the file path I passed in is like this
sys.path.append('c:\Users\mshacxiang\VScode_ project\web_ ddt')
Cause analysis: the file path can be read in the windows system, but \ has escape meaning in the Python string. For example, \ t can represent tab and \ n represents line feed. Therefore, we need to take some measures to prevent \ from being interpreted as escape characters. Add r before the path to keep the original value of the character. This solves the problem
sys.path.append(r'c:\Users\mshacxiang\VScode_ project\web_ ddt')
Read More:
- python SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: trunca
- Python SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3:
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- How to solve the problem of syntax error: (Unicode error)’unicodescape ‘codec can’t decode bytes in position 2-3: truncat
- Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd3 in position 238: invalid continuation B
- Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte
- Successfully resolved Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd3 in position 238: invalid continuation B
- Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte solution
- When reading the CSV file with Python 3, the Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd0 in position 0: invalid con appears
- Run Python file for the first time with eclipse / pydev: “UTF-8 ‘codec can’t decode byte 0xc4 in position
- ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in range(128)
- UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd6 in position 3089: invalid continuation byte
- Solve the ‘UTF-8’ codec can’t decode byte 0xe9 in position 3114: invalid continuation byte error
- UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xc3 in position 54: invalid continuation byte
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-2: ordinal not in range(128)
- Error resolution of unexpected token in JSON at position 0
- Unicode encodeerror: ‘GBK’ codec can’t encode character solution
- Error: syntax error – unexpected token P in JSON at position 0
- Syntax error or access violation: 1071 specified key was too long; max key length is 767 bytes