監督は最近、メソッドftplibのモジュールで、ソースコードを見て、戻り値を発見しませんが、標準出力ストリームにデフォルト設定されます、返品なしを見つけていない、変数リターンで格納ディレクトリについて考え、BaiduのBaiduは一瞬のためではありませんでしたソリューションへ。
ディレクトリの方法は#Ftplibモジュールなし戻り値が定義されました
def dir(self, *args):
'''List a directory in long form.
By default list current directory to stdout.
Optional last argument is callback function; all
non-empty arguments before it are concatenated to the
LIST command. (This *should* only be used for a pathname.)'''
cmd = 'LIST'
func = None
if args[-1:] and type(args[-1]) != type(''):
args, func = args[:-1], args[-1]
for arg in args:
if arg:
cmd = cmd + (' ' + arg)
self.retrlines(cmd, func)
いくつかの研究とdirsには、戻り値の問題を解決することができるftplibの新しいソースコードに直接メソッドを記述が見つかりました:
ここでtemplistと、それはすべてのディレクトリのリストを返します。
def dirs(self, *args):
'''List a directory in long form.
By default list current directory to stdout.
Optional last argument is callback function; all
non-empty arguments before it are concatenated to the
LIST command. (This *should* only be used for a pathname.)'''
cmd = 'LIST'
templist = []
func = None
if args[-1:] and type(args[-1]) != type(''):
args, func = args[:-1], args[-1]
for arg in args:
if arg:
cmd = cmd + (' ' + arg)
self.retrlines(cmd, templist.append)
return templist