问题描述
在Python中编码并执行以下代码行时:
print("https://stackoverflow.com/")
它在运行控制台中显示为非常漂亮的链接=)。
但是如何使用本地路径将其存档?
不起作用的是:
print("file:///C:\Programs\something")
print("C:\Programs\something")
解决方法
您必须将这些反斜杠转换为正斜杠:
print("file:///C:\Programs\something".replace('\\','/'))