Page 49 - Python rat la co ban
P. 49

khỏi hệ thống. Ví dụ:





           import os

           os.remove('test.txt')






          5.2. Thư mục (Directory)





          5.2.1. 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')







          5.2.2. 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')
   44   45   46   47   48   49   50   51   52   53   54