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 allfilesFollower me
Facebook: https://www.facebook.com/lamsaodecode
Last updated
Was this helpful?