SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UX
程序员文章站
2022-06-15 13:40:19
...
从某段路径(文件夹中)取出一个文件,读取内容,进行处理,报错:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
原来的文件路径是:
file_path = 'C:\Users\zzuzh\Desktop\flower_photos\flower_photos\roses\12240303_80d87f77a3_n.jpg'
解决办法是:
在路径字符串前面加上 r
r表示原始字符串
file_path = r'C:\Users\zzuzh\Desktop\flower_photos\flower_photos\roses\12240303_80d87f77a3_n.jpg'
上一篇: JavaScript继承
下一篇: javascript继承
推荐阅读
-
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
-
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
-
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
-
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
-
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