【发布时间】:2021-01-13 12:43:13
【问题描述】:
netowrk_path = '\\shared_storage\test.txt'
cmd = f'/c copy {netowrk_path} D:\\temp'
print(cmd)
这会在复制时打印并给出错误
/c copy \shared_storage test.txt D:\temp
但它实际上应该打印
/c copy \\shared_storage test.txt D:\temp
【问题讨论】:
-
反斜杠在 Python 字符串文字中被特别解释,在字符串前面加上“r”,如 e。 G。
r'\\shared_storage'.