python,一个for循环语句调用有关问题,请问
python,一个for循环语句调用问题,请教
find函数里为什么写成startdir=os.curdir?
函数调用时,startdir到底是等于self.dirpath.GetValue()还是os.curdir?
self.find(self.filename.GetValue(),self.dirpath.GetValue())
def find(self,pattern,startdir=os.curdir):
for (thisdir, subdirs,fileshere) in os.walk(startdir):
for filename in fileshere:
if fnmatch.fnmatch(filename, pattern):
fullpatch = os.path.join(thisdir, filename)
self.matches.append(fullpatch)
------解决方案--------------------
startdir=os.curdir 这是默认设定
就是说你不传入startdir参数(省略)时就默认使用os.curdir,但如果传入,就使用所传入的值
例如
def abc(a, b=0):
print(a, ',', b)
abc(1,2) 得到 1,2
abc(1) 得到 1,0
find函数里为什么写成startdir=os.curdir?
函数调用时,startdir到底是等于self.dirpath.GetValue()还是os.curdir?
self.find(self.filename.GetValue(),self.dirpath.GetValue())
def find(self,pattern,startdir=os.curdir):
for (thisdir, subdirs,fileshere) in os.walk(startdir):
for filename in fileshere:
if fnmatch.fnmatch(filename, pattern):
fullpatch = os.path.join(thisdir, filename)
self.matches.append(fullpatch)
Python
------解决方案--------------------
startdir=os.curdir 这是默认设定
就是说你不传入startdir参数(省略)时就默认使用os.curdir,但如果传入,就使用所传入的值
例如
def abc(a, b=0):
print(a, ',', b)
abc(1,2) 得到 1,2
abc(1) 得到 1,0