> For the complete documentation index, see [llms.txt](https://lamsaodecode.gitbook.io/python-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lamsaodecode.gitbook.io/python-reference/folder.md).

# Folder

## Tạo thư mục

Sử dụng phương thức `os.mkdir(dir)` để tạo thư mục.

#### Ví dụ:

```python
import os
os.mkdir('test')
```

## Xóa thư mục

Sử dụng phương thức `os.rmdir(dir)` để xóa một thư mục.

#### Ví dụ:

```python
import os
os.rmdir('test')
```

## Đọc thư mục

Sử dụng phương thức `os.listdir(dir)` để lấy danh sách tập tin, thư mục của thư mục `dir` . Khi gọi sẽ trả về một mảng danh sách các tập tin, thư mục.

#### Ví dụ:

```python
import os
allfiles = os.listdir('/root/downloads')
print allfiles
```

## Follower me

* **Facebook**: [https://www.facebook.com/lamsaodecode](https://www.facebook.com/100013678592616)
* **Blog:** <https://lamsaodecode.blogspot.com>
* **Github:** <https://lamsaodecode.github.io/introduction>
