is there any way to identify whether an object is file or directory using st_mode value? I'm using paramiko lstat() to retrieve the st_mode information from sftp files.
Yes, the stat structure st_mode
does contain that information.
Use the stat
module to determine if it is a directory:
import stat
if stat.S_ISDIR(lstat_result.st_mode):
来源:https://stackoverflow.com/questions/15861967/using-st-mode-to-identify-file-or-directory