关闭UNC路径的copy \ copyfile文件

时间:2019-08-12 03:41:23

标签: python-3.x shutil os.path pathlib

无法关闭文件。正在尝试os.path和pathlib库,在stackoverflow和其他资源中阅读了许多有关它的问题,但仍然不明白为什么它不起作用

使用python 3.7。需要在Windows和Unix中执行

BASE_DIR = pathlib.Path('//unc/path/to/folder')

to_dir = pathlib.Path.cwd().joinpath("copy_here")
folder = 'folder'
obj = 'file.png'

file_parts = [folder, obj]
from_path = pathlib.Path(BASE_DIR).joinpath(*file_parts)
print(from_path.__repr__())
print(from_path.__str__())
shutil.copy(from_path, to_dir)

WindowsPath('//unc/path/to/folder/folder/file.png')
\\unc\path\to\folder\folder\file.png
FileNotFoundError: [Errno 2] No such file or directory: '\\\\unc\\path\\to\\folder\\folder\\file.png``

为什么仍然显示“ \\\\”和“ \\”错误?

0 个答案:

没有答案