Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1]
- # Get the absolute path to directory which contains the Python script you want to/are run(ning)
- # Note: Folder <==> Directory
- # E.g.: Absolute (abs) path to the directory (dir): C:\Users\John\ProjectXFolder\ProjectXSubFolder
- # E.g.: Absolute (abs) path to the Python script: C:\Users\John\ProjectXFolder\ProjectXSubFolder\get_data.py
- # get_data.py
- import os
- script_path = os.path.dirname(os.path.abspath(__file__))
- print("script_path: ", script_path)
- #returns
- C:\Users\John\ProjectXFolder\ProjectXSubFolder
- # 2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement