我正在尝试将文件保存到映射的网络驱动器 Z: & 我收到的错误是 SyntaxError: 'EOL while Scaning stringoral'。我已经在本地驱动器上尝试过此代码,没有任何问题。有关引用映射共享云端硬盘的任何提示。
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)
关于Python 保存到映射共享驱动器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58530301/