Python 保存到映射的共享驱动器错误

Python Saving to Mapped Shared Drive Error

我正在尝试将文件保存到映射的网络驱动器 Z: & 我遇到的错误是 SyntaxError: 'EOL while scanning string lateral'。我已经在本地驱动器上尝试过此代码,没有任何问题。有关引用映射共享驱动器的任何提示。

with open ('test.txt','r') as file:
    text = file.read()
    with open(' Z:\example.job.com@SSL\site\more\specific\folder\files','w') as file:
        file.write(text)

你没有转义反斜杠吗? 尝试:

directory = r"Z:\example.job.com@SSL\site\more\specific\folder\files"
with open ('test.txt','r') as file:
    text = file.read()
    with open(directory,'w') as file:
        file.write(text)