path='D:\\baiduImage\小新\%D0%A1%D0%C2%B3%F6%C9%FA%B8%B8%C7%D7%B5%C4%D3%A2%B3%DF-13214820.jpg'
path='D:\baiduImage\小新\%D0%A1%D0%C2%B3%F6%C9%FA%B8%B8%C7%D7%B5%C4%D3%A2%B3%DF-13214820.jpg'
\b会被解析成其他字符,如下图
说明:字符串前加r与不加r是有区别的.加r,防止字符串被转义,入\t如果没有加r就会被转义
如下
path=r'D:\baiduImage\小新\%D0%A1%D0%C2%B3%F6%C9%FA%B8%B8%C7%D7%B5%C4%D3%A2%B3%DF-13214820.jpg'
print filetype(path)
报错
IOError: [Errno 2] No such file or directory: 'D:\\baiduImage\\\xe5\xb0\x8f\xe6\x96\xb0\\%D0%A1%D0%C2%B3%F6%C9%FA%B8%B8%C7%D7%B5%C4%D3%A2%B3%DF-13214820.jpg'
正确姿势
path=r'D:\baiduImage\小新\%D0%A1%D0%C2%B3%F6%C9%FA%B8%B8%C7%D7%B5%C4%D3%A2%B3%DF-13214820.jpg'
upath=unicode(path,'utf8')
print filetype(upath)
以上代码均在windows上测试运行