- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print full path of current file's directory in Python?
To get current file's full path, you can use the os.path.abspath function. If you want only the directory path, you can call os.path.dirname.
import os absolute_path = os.path.abspath(__file__) print("Full path: " + absolute_path) print("Directory Path: " + os.path.dirname(absolute_path))
This will give the output:
Full path: C:\python27\test.py Directory path: C:\python27\
- How to get full path of current file's directory in Python?
- How to extract a part of the file path (a directory) in Python?
- How to print current package cache directory information in android?
- How to change current directory using Python?
- How to find current directory of program execution in Python?
- How to know current working directory in Python?
- How to import a Python module given the full path?
- How to know/change current directory in Python shell?
- How to set the current working directory in Python?
- How to change the root directory of the current process in Python?
- Get the absolute path for the directory or file in Java
- Specify a path for a file or a directory in Java
- File and Directory Comparisons in Python
- Program for longest common directory path in Python
- Java Program to get the File object with the absolute path for the directory or file