Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将模式列表发送到copytree';s ignore_patterns给出TypeError:unhable type:';列表';_Python_Copytree - Fatal编程技术网

Python 将模式列表发送到copytree';s ignore_patterns给出TypeError:unhable type:';列表';

Python 将模式列表发送到copytree';s ignore_patterns给出TypeError:unhable type:';列表';,python,copytree,Python,Copytree,我正在编写一个python脚本,当我尝试使用扩展列表作为copytree的ignore_模式时,它抛出一个TypeError:unhabable类型:“list”。我不确定,1。为什么这行不通,还有2。如何着手修复它 # allFileTypes is the list of all extensions in source_dir # grabbed with function getFileExtList allFileTypes = getFileExtList(source_dir) #

我正在编写一个python脚本,当我尝试使用扩展列表作为copytree的ignore_模式时,它抛出一个TypeError:unhabable类型:“list”。我不确定,1。为什么这行不通,还有2。如何着手修复它

# allFileTypes is the list of all extensions in source_dir
# grabbed with function getFileExtList
allFileTypes = getFileExtList(source_dir)
# delete the blank file type
del allFileTypes[0]

#  Open a window to choose the files to copy
copyList = eg.multchoicebox(msg='Select the file types to copy',
                choices=(allFileTypes))

# List comprehension to make an ignore list for copytree
ignoreList = [x for x in allFileTypes if x not in copyList]


# Open a window to choose the destination directory
root_dir = eg.diropenbox(title='Choose Destination Directory')

# Take the basename of source_dir adding it to root_dir or os.mkdir will
# will break on the existing directory
dest_dir = os.path.join(root_dir, os.path.basename(source_dir))

# copytree everything from the source_dir to the dest_dir ignoring
# all files types not chosen from the list
copytree(source_dir, dest_dir, ignore=ignore_patterns(ignoreList))
ignore_patterns
将所有模式作为位置参数而不是列表接收

copytree(source_dir, dest_dir, ignore=ignore_patterns(*ignoreList))