📃
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
  • Module os
  • Module os.path
  • Follower me

Was this helpful?

Module os

Module os

Module os là một module có nhiều phương thức hữu ích trong việc làm việc với các file và directory, như:

  • os.chdir(path) Đổi thư mục hiện hành.

  • os.getcwd() Trả về thư mục hiện hành.

  • os.chmod(path, mode) CHMOD một đường dẫn.

  • os.chown(path, uid, gid) CHOWN một đường dẫn.

  • os.makedirs(path[, mode]) Tạo đường dẫn (có recursive).

  • os.removedirs(path) Xóa một đường dẫn (có recursive).

Module os.path

Module os.path hỗ trợ các phương thức giúp thao tác nhanh chóng và thuận tiện hơn trên đường dẫn.

  • os.path.exists(path) Kiểm tra 1 đường dẫn có tồn tại hay không.

  • os.path.getsize(path) Lấy file size (byte).

  • os.path.isfile(path) Kiểm tra xem có phải là một file thông thường.

  • os.path.isdir(path) Kiểm tra xem có phải là một thư mục.

  • os.path.dirname(path) Trả về tên thư mục của path.

  • os.path.getatime(path) Trả về thời gian truy cập mới nhất.

  • os.path.getmtime(path) Trả về thời gian chỉnh sửa cuối cùng.

  • os.path.getctime(path) Trả về thời gian chỉnh sửa cuối của metadata trên một số hệ thống. Hoặc trả về thời gian tạo file trên Windows.

Follower me

PreviousFolderNextImage

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