【问题标题】:Python Saving to Mapped Shared Drive ErrorPython保存到映射的共享驱动器错误
【发布时间】:2019-10-23 20:08:58
【问题描述】:

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

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)

【问题讨论】:

    标签: python save shared drive


    【解决方案1】:

    你没有避开反斜杠吗? 试试:

    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)
    

    【讨论】:

    • 效果很好,但现在我收到“权限被拒绝:Z:\\example.job.com@SSL\site\more\specific\folder\files”
    • 可能写请求被拒绝了。查看脚本是否具有对相关目录的读/写访问权限。我认为,可能与您用户的访问权限不同。可能基于 python.exe 在哪里? (在管理员安装与用户安装中)
    猜你喜欢
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-10
    • 2021-11-05
    • 2021-06-27
    • 2020-02-03
    • 2012-02-16
    相关资源
    最近更新 更多