Skip to content

Instantly share code, notes, and snippets.

View ltaoist's full-sized avatar
🏢
Working from Office

21世纪工科青年 ltaoist

🏢
Working from Office
  • 历史现实主义
View GitHub Profile
@ltaoist
ltaoist / listdir.py
Created November 23, 2018 13:52 — forked from Tachiguishi/listdir.py
Python 遍历当前目录下的文件
# 只可以遍历指定文件夹rootdir中的文件夹名和文件名
# 无法遍历出其中包含的子文件夹中的内容
import os
rootdir = './' # 需要遍历的文件夹,这里设定为当前文件夹
list = os.listdir(rootdir)
for line in list:
filepath = os.path.join(rootdir, line)
if os.path.isdir(filepath):