使用 st_mode 来识别文件或目录 [英] using st_mode to identify file or directory
本文介绍了使用 st_mode 来识别文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用 st_mode 值来识别对象是文件还是目录?我正在使用 paramiko lstat() 从 sftp 文件中检索 st_mode 信息.
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.
推荐答案
是的,stat 结构 st_mode
确实包含该信息.
Yes, the stat structure st_mode
does contain that information.
使用 stat
模块来确定是否它是一个目录:
Use the stat
module to determine if it is a directory:
import stat
if stat.S_ISDIR(lstat_result.st_mode):
这篇关于使用 st_mode 来识别文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文