如何使用IP地址代替Python中的映射驱动器号

问题描述 投票:0回答:1

早安

我目前已经开发了一段代码,可以将文件从一个位置复制到另一个位置。我目前正在尝试指定特定的staticv IP地址,而不是使用从PC到PC更改的动态驱动器号。

当前我的代码如下:

import glob
import os
import shutil
import easygui


def copy(src):
  destination = easygui.diropenbox()
  list_of_files = glob.glob(src)  # * means all if need specific format then *.csv
  latest_file = max(list_of_files, key=os.path.getctime)
  shutil.copy(latest_file, destination)


copy('C:\Users\micha\Desktop\Test_Copy1\*')

[而不是使用copy('C:\Users\micha\Desktop\Test_Copy1\*'),我正在考虑使用以下内容:\\ip-address\Users\micha\Desktop\Test_Copy1\*。我尝试使用UNC,但是这意味着我必须绕过登录页面。

如果有人可以帮助,将不胜感激。

python python-2.7 ip-address
1个回答
0
投票

我完成此任务的方式是使用请求库

import requests
url = 'https://www.python.org/static/img/[email protected]'
myfile = requests.get(url)
open('c:/users/LikeGeeks/downloads/PythonImage.png', 'wb').write(myfile.content)

以上示例来自here

© www.soinside.com 2019 - 2024. All rights reserved.