报错原因:原因:window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,经过转义之后可能就找不到路径的资源了,例如\t会转义为tab键
解决方案:
1. 更换为绝对路径的写法
func1("C:\\Users\\renyc")
2. 显式声明字符串不用转义(加r)
func1(r"C:\Users\renyc")
3. 使用Linux的路径/
func1("C:/Users/renyc")
报错原因:原因:window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,经过转义之后可能就找不到路径的资源了,例如\t会转义为tab键
解决方案:
1. 更换为绝对路径的写法
func1("C:\\Users\\renyc")
2. 显式声明字符串不用转义(加r)
func1(r"C:\Users\renyc")
3. 使用Linux的路径/
func1("C:/Users/renyc")