I'm trying to copy dir1 to dir2. Dir1 contains sub-folders and files. In the moment of copy I'm creating url like this C:/dirA/dir1
and C:/dirB/dir2
. As you see all slashes are forwarded. When run I get this error
No such file or directory path C:/dirB/dir2\\folder1\\file.txt
As you see sub-folder and file have backslashes. I really do not know how to change that backslashes because when I create a paths I don't know the names of sub-folders/files. I can't post entire code because it's huge. To copy I use distutils.dir_util.copy_tree
.
在连接之前,您似乎可以在路径的某些部分上使用os.path.normpath
来对当前操作系统进行规范化,在Windows上它将使用正确的斜杠。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.