Bạn có thể kiểm tra xem tệp là thư mục hay tệp bằng phương thức os.path.isfile:
Ví dụ
>>> import os
>>> print os.path.isfile('my_file.txt')
True
>>> print os.path.isfile('my_folder')
False Bạn có thể kiểm tra xem tệp là thư mục hay tệp bằng phương thức os.path.isfile:
>>> import os
>>> print os.path.isfile('my_file.txt')
True
>>> print os.path.isfile('my_folder')
False