【问题标题】:Changing the directory using os.chdir UNC filepath in python在 python 中使用 os.chdir UNC 文件路径更改目录
【发布时间】:2019-08-13 14:37:09
【问题描述】:

我正在尝试通过其 IP 地址或使用它的 unc 更改目录(因为我在 Windows 中工作)。这是由于外部服务器被映射到不同用户的不同驱动器。

使用 os.chdir(r'path\\to\remote\directory') 似乎不起作用,我想知道是否有任何 Python 不讨厌的替代方案,即 IP 地址?

【问题讨论】:

    标签: python operating-system ip-address


    【解决方案1】:

    对我来说很好用:

    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> os.chdir(r"\\myserver\myshare")
    >>> os.getcwd()
    '\\\\myserver\\myshare'
    

    很难判断r'path\\to\remote\directory' 错字是否也在您的实际代码中,以及您如何确定它“不起作用”。

    【讨论】:

      猜你喜欢
      • 2017-10-22
      • 1970-01-01
      • 2023-01-11
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-10
      相关资源
      最近更新 更多