Python: Check whether a file path is a file or a directory - w3resource

PHOTO EMBED

Sat Oct 17 2020 16:14:28 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol #python

import os  
path="abc.txt"  
if os.path.isdir(path):  
    print("\nIt is a directory")  
elif os.path.isfile(path):  
    print("\nIt is a normal file")  
else:  
    print("It is a special file (socket, FIFO, device file)" )
print()


content_copyCOPY

https://www.w3resource.com/python-exercises/python-basic-exercise-85.php