from stat import S_ISDIRdef isdir(path): try: return S_ISDIR(sftp.stat(path).st_mode) except IOError: #Path does not exist, so by definition not a directory return False
…假设
sftp是开放的Paramiko SFTP连接。

from stat import S_ISDIRdef isdir(path): try: return S_ISDIR(sftp.stat(path).st_mode) except IOError: #Path does not exist, so by definition not a directory return False
…假设
sftp是开放的Paramiko SFTP连接。