SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 133-134: malformed

报错原因:原因:window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,经过转义之后可能就找不到路径的资源了,例如\t会转义为tab键

解决方案:

1. 更换为绝对路径的写法
func1("C:\\Users\\renyc")

2. 显式声明字符串不用转义(加r)
func1(r"C:\Users\renyc")

3. 使用Linux的路径/
func1("C:/Users/renyc")

猜你喜欢

转载自blog.csdn.net/weixin_61745097/article/details/128341256