擅长:python、mysql、java
<p>好吧,我像建议的那样使用关键字参数。在</p>
<pre><code>def compareNfilesParameters(listFiles, **kwargs):
start_time = time.time()
if len(listFiles) < MINUMUM_FILES_NUMBER :
print "You need to specify at least "+ str(MINUMUM_FILES_NUMBER) +" files."
return
try:
operationType = int(kwargs.get("op", DEFAULT_OPERATION_TYPE))
except ValueError:
print "Operation type filter has to be an integer."
return
if operationType not in [0,1]:
print "Operation type must be 0 (intersection), 1 (union)"
return
</code></pre>
<p>以此类推。
像这样,我需要把所有的文件路径放在一个列表中,并将其作为一个必需的参数传递,然后搜索kwargs字典中的可选参数,如果参数没有表达,则设置默认值。在</p>