Python 保存到映射共享驱动器时出错

标签 python save shared drive

我正在尝试将文件保存到映射的网络驱动器 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/

相关文章:

c++ - 在c++中相对保存文件

c - Linux 中的两个不同进程如何调用一个共享库文件?

python - 关闭 urllib2 连接

python - 如何从键列表和值列表创建字典列表

python - 如何在 python 中选择多个列

visual-studio - 如何在 Visual Studio 2012 中保存打开的选项卡和选项卡组?

java - 在 Java Swing 中保存文件时检查文件是否存在

gcc - 使用 -rpath 和 $ORIGIN 链接时查找失败

pointers - shared_ptr 不改变对象(Visual Studio 2012)

python - Django 减少查询