Shutil.copytree ----> WindowsError: [Error 3] The system cannot find the path specified:
Shutil.copytree ----> WindowsError: [Error 3] The system cannot find the path specified:
我正在尝试从源中提取内容并移至目标文件夹。
folder1 = 2018
folder2 = 8
folder3 = 3
source = os.path.join("C:\","Pizza","Sammy","Logs", "Archive", "DataLog_Private" ,str(folder1),"0" + str(folder2),"0" + str(folder3))
destination = os.path.join("C:\","Users", "alex", "Desktop", "logPull" , "DataLog_Private" ,str(folder1),"0" + str(folder2),"0" + str(folder3))
shutil.copytree(source,destination)
这条路我也试过
#source = r"C://Pizza//Sammy//Logs//Archive//DataLog_Private//%s//%s//%s//" %(str(folder1),"0" + str(folder2),"0" + str(folder3))
#destination = r"C://Users//alex//Desktop//logPull//DataLog_Private//%s//%s//%s//" %(str(folder1),"0" + str(folder2),"0" + str(folder3))
在使用 copytree
时,我在两条路径上都遇到了这个错误
WindowsError: [Error 3] The system cannot find the path specified'C:\Pizza\Sammy\Logs\Archive\DataLog_Private\2018\08\03/*.*'
请帮忙。
以下是我在Python3.6下的作品,注意环境变量的使用。
import os
import shutil
folder1 = 2018
folder2 = 8
folder3 = 3
drive = os.path.join(os.getenv("HOMEDRIVE"), os.sep)
date_path = os.path.join(f"{folder1}", f"{folder2:02}", f"{folder3:02}")
source = os.path.join(
drive, "Pizza","Sammy", "Logs", "Archive", "DataLog_Private", date_path
)
destination = os.path.join(
os.getenv("USERPROFILE"), "Desktop", "logPull", "DataLog_Private", date_path
)
shutil.copytree(source, destination)
HOMEDRIVE
应该指向安装了 Windows 的任何磁盘。列出 if 默认环境变量 here
f"{expression}"
符号称为 f 字符串。这是在 Python 3.6、here's the PEP 中引入的。在方括号内添加 :02
会给数字一个前导 0。
我正在尝试从源中提取内容并移至目标文件夹。
folder1 = 2018
folder2 = 8
folder3 = 3
source = os.path.join("C:\","Pizza","Sammy","Logs", "Archive", "DataLog_Private" ,str(folder1),"0" + str(folder2),"0" + str(folder3))
destination = os.path.join("C:\","Users", "alex", "Desktop", "logPull" , "DataLog_Private" ,str(folder1),"0" + str(folder2),"0" + str(folder3))
shutil.copytree(source,destination)
这条路我也试过
#source = r"C://Pizza//Sammy//Logs//Archive//DataLog_Private//%s//%s//%s//" %(str(folder1),"0" + str(folder2),"0" + str(folder3))
#destination = r"C://Users//alex//Desktop//logPull//DataLog_Private//%s//%s//%s//" %(str(folder1),"0" + str(folder2),"0" + str(folder3))
在使用 copytree
WindowsError: [Error 3] The system cannot find the path specified'C:\Pizza\Sammy\Logs\Archive\DataLog_Private\2018\08\03/*.*'
请帮忙。
以下是我在Python3.6下的作品,注意环境变量的使用。
import os
import shutil
folder1 = 2018
folder2 = 8
folder3 = 3
drive = os.path.join(os.getenv("HOMEDRIVE"), os.sep)
date_path = os.path.join(f"{folder1}", f"{folder2:02}", f"{folder3:02}")
source = os.path.join(
drive, "Pizza","Sammy", "Logs", "Archive", "DataLog_Private", date_path
)
destination = os.path.join(
os.getenv("USERPROFILE"), "Desktop", "logPull", "DataLog_Private", date_path
)
shutil.copytree(source, destination)
HOMEDRIVE
应该指向安装了 Windows 的任何磁盘。列出 if 默认环境变量 here
f"{expression}"
符号称为 f 字符串。这是在 Python 3.6、here's the PEP 中引入的。在方括号内添加 :02
会给数字一个前导 0。