编写一个函数在字符串前面+r,使得程序可以读取文件路径


path_t ="D:\worksapce_python\20160426_cp\training"

编写一个函数,当传入path_t,可以返回

path_t =r"D:\worksapce_python\20160426_cp\training"

字符串前+r,实际是把string 转成 raw string,使其中\的转义不生效
python 提供了内置方法
repr(string)

如果有帮助,请点个采纳哦~

直接在前面手动加r上去不就行了