What is os.path.dirname() method in python
Oct. 2, 2020, 12:14 p.m.
os.path.dirname() returns the directory of a given path name e.g. if the given path is '/home/felix/Documents' , os.path.dirname() will return "/home/felix" . you can try this in your terminal like this
import os
# our sample path, yours might be different
sample_path = '/home/felix/Documents'
directory_name = os.path.dirname(sample_path)
print(directory_name)
the output of the above code will be
/home/felix
Resources
Keep Learning
- Django Translation To Different Languages Example
- How Does Django and Celery Work
- Chains, Groups and Chords in Celery