📃
Python Reference
  • Installation
  • First Steps
  • Variables
  • Operators and Expressions
  • Control Flow
  • Loops
  • Functions
  • String
  • List
  • Dictionany
  • Modules
  • Class
  • File
  • Folder
  • Module os
  • Image
  • JSON
  • XML
  • Connection MySQL
  • Connection Redis
  • Connection Memcached
  • Connection RabbitMQ
  • Restful client
  • STMP
  • Socket
Powered by GitBook
On this page
  • Tạo thư mục
  • Xóa thư mục
  • Đọc thư mục
  • Follower me

Was this helpful?

Folder

Tạo thư mục

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

Ví dụ:

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ụ:

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ụ:

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

Follower me

PreviousFileNextModule os

Last updated 4 years ago

Was this helpful?

Facebook:

Blog:

Github:

https://www.facebook.com/lamsaodecode
https://lamsaodecode.blogspot.com
https://lamsaodecode.github.io/introduction