Python论坛  - 讨论区

标题:[python-chinese] 如何列出某个路径下的所有文件?

2006年04月09日 星期日 09:58

Geoffery>>>嘎瑞>>>XuLi geofferyli at gmail.com
Sun Apr 9 09:58:33 HKT 2006

谢谢

--
-------------------------------------------------------------------
python-chinese list
Python中文技术讨论邮件列表
发言: 发邮件到 python-chinese at lists.python.cn
订阅: 发送 subscribe 到 python-chinese-request at lists.python.cn
退订: 发送 unsubscribe 到  python-chinese-request at lists.python.cn
详细说明: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060409/60c0dab7/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月09日 星期日 13:50

Lee DYER lee.dyer at gmail.com
Sun Apr 9 13:50:38 HKT 2006

在06-4-9,Geoffery>>>嘎瑞>>>XuLi <geofferyli at gmail.com> 写道:
import os
os.listdir('路径名')


_______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060409/4b0cd386/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月09日 星期日 16:34

Geoffery>>>嘎瑞>>>XuLi geofferyli at gmail.com
Sun Apr 9 16:34:42 HKT 2006

谢谢

On 4/9/06, Lee DYER <lee.dyer at gmail.com> wrote:
>
>
>
> 在06-4-9,Geoffery>>>嘎瑞>>>XuLi <geofferyli at gmail.com> 写道:
> import os
> os.listdir('路径名')
>
>
> _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
-------------------------------------------------------------------
python-chinese list
Python中文技术讨论邮件列表
发言: 发邮件到 python-chinese at lists.python.cn
订阅: 发送 subscribe 到 python-chinese-request at lists.python.cn
退订: 发送 unsubscribe 到  python-chinese-request at lists.python.cn
详细说明: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060409/c8c2857b/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月09日 星期日 16:59

Leo Jay python.leojay at gmail.com
Sun Apr 9 16:59:28 HKT 2006

可以参考glob模块和os模块里的walk及listdir函数


--
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月09日 星期日 17:18

清风 paradise.qingfeng at gmail.com
Sun Apr 9 17:18:38 HKT 2006

def all_files(pattern, search_path, pathsep=os.pathsep):
    """ Given a search path, yield all files matching the pattern. """
    for path in search_path.split(pathsep):
        for match in glob.glob(os.path.join(path, pattern)):
            yield match.replace('\','/')

if __name__=='__main__':
    print list(all_files('*.swf', 'images/swf'))[::-1]

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号