我创建了两个数组,让python获取用户输入来填充这些数组,如下所示:
#Establish the number directory paths
print "How many additional directories will you need to copy?"
dirCount = int(raw_input(prompt))
srcDirList = []
dstDirList = []
我想对它们进行迭代,并将srcDirList中的数据复制到dstDirList中相应的值中。我是这样安排的:
#iterate through both source and destination arrays and
#copy the additionally specified source directories to destination directories
for src, dst in zip(srcDirList, dstDirList):
dir_copy(src, dst)
然而,我的剧本似乎只是停留在这里。它不会像预期的那样复制,也不会退出或抛出错误。我有某种无限循环吗?这仅仅是一种可怕的实现方式吗?你知道吗
编辑:下面是dir\u copy的代码:
#copy function
def dir_copy(srcpath, dstdir):
#set destination dirname to share basename with the source directory
dirname = os.path.basename(srcpath)
#set the actual directory path
dstpath = os.path.join(dstdir, dirname)
shutil.copytree(srcpath, dstpath)
目前没有回答
相关问题 更多 >
编程相关推荐