def f(s): # s.replace() 返回一个新的字符串,将 \ 替换为 / return s.replace("\\", "/") # 注意:在 Python 字符串中,\ 是转义字符,所以表示一个反斜杠需要使用 \\ sss = f("public\videos\产品视频\小喷瓶(差旅神器)\小喷子(差旅神器)-3-中文.mp4") print(sss)