小编use*_*482的帖子

在python中查找所有linux文件的通用目录

我想找到python中所有linux文件(不是目录)的通用目录.大家可以帮帮我吗?

例1:

['/home/tung/abc.txt', '/home/tung/xyz.txt']
    -> general directory: '/home/tung'
Run Code Online (Sandbox Code Playgroud)

例2:

['/home/tung/abc.txt', '/home/tung/xyz.txt', '/home/user/123.txt']
    -> general directory: '/home'
Run Code Online (Sandbox Code Playgroud)

示例3:

['/home/tung/abc.txt', '/root/xyz.txt']
    -> general directory: '/'
Run Code Online (Sandbox Code Playgroud)

python linux algorithm

2
推荐指数
1
解决办法
80
查看次数

标签 统计

algorithm ×1

linux ×1

python ×1