Deb*_*ian 1 python file list absolute-path uid
我正在尝试编写一个 python 脚本,以递归方式列出给定目录中具有绝对路径的所有文件,并在它们前面列出它们的 UID 和文件所有者。(类似于: ls -lR )我写了这个,但它在执行结束时给了我一个错误:
import os
for folder, subfolders, files in os.walk(os.getcwd()):
for file in files:
filePath = os.path.abspath(file)
print(filePath, os.stat(file).st_uid)
Run Code Online (Sandbox Code Playgroud)
import os
import glob
for filename in glob.iglob('./**/*', recursive=True):
print(os.path.abspath(filename), os.stat(filename).st_uid)
Run Code Online (Sandbox Code Playgroud)
需要 Python 3.5 或更高版本 在 Python 中使用 Glob() 递归查找文件?
| 归档时间: |
|
| 查看次数: |
8259 次 |
| 最近记录: |