Syntax Error: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position resolution

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: