Python path backslash replacement, modify file suffix name

Backslash replacement and file extension modification in file path

文件路径和名称:
xlsPath=D:\Python\files\文件.pdf
xlsPath = (filePath[:-3] + "xls")
print(xlsPath)
D:\Python\files\文件.xls

路径中的反斜杠替换
xlsPath=D:/Python/files/文件.xls
xlsPath=xlsPath.replace('\\', "/")
print(xlsPath)
D:/Python/files/文件.xls

Guess you like

Origin blog.csdn.net/tone1128/article/details/105538536