【问题标题】:Python use of wnet_connect(host, username = None, password = None)Python 使用 wnet_connect(host, username = None, password = None)
【发布时间】:2013-03-19 20:41:34
【问题描述】:

我正在尝试连接到 DNS 中未列出的服务器,它只是一个具有 ip 的服务器。

使用此代码我没有运气:

netpath = r'\\10.5.1.22\Products'
    networkPath = netpath
    unc = ''.join(['\\\\', host])
    print unc
    try:
            win32wnet.WNetAddConnection2(0, None, unc, None, username, password)
    except Exception, err:
        if isinstance(err, win32wnet.error):
            #Disconnect previous connections if detected, and reconnect.
            if err[0] == 1219:
                win32wnet.WNetCancelConnection2(unc, 0, 0)
                return wnet_connect(host, username, password)
        raise err

在我使用 Python 2.7 的这种情况下,有没有更好的连接方式

【问题讨论】:

    标签: python wnet


    【解决方案1】:

    如果不在 DNS 中,则无法连接到服务器或任何机器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 2020-05-20
      • 2019-07-31
      相关资源
      最近更新 更多