查找笔记本电脑的所有目录和文件 [英] Find all directories and files of your laptop

查看:190
本文介绍了查找笔记本电脑的所有目录和文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何用Python编写代码以查找所有文件系统,包括从根到当前计算机系统的每个文件的文件.

How can we write code in Python​ to find all file system including files from root to each and every file of the current computer system.

推荐答案

您可以使用os.walk方法.这是一个示例:

You can use the os.walk method. Here is an example:

# !/usr/bin/python

import os
for root, dirs, files in os.walk(".", topdown=False):
    for name in files:
        print(os.path.join(root, name))
    for name in dirs:
        print(os.path.join(root, name))

http://www.tutorialspoint.com/python/os_walk.htm

请参阅完整文档: https://docs.python.org /2/library/os.html#os.walk

这篇关于查找笔记本电脑的所有目录和文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆