Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. # 1]
  2. # Get the absolute path to directory which contains the Python script you want to/are run(ning)
  3. # Note: Folder <==> Directory
  4. # E.g.: Absolute (abs) path to the directory (dir): C:\Users\John\ProjectXFolder\ProjectXSubFolder
  5. # E.g.: Absolute (abs) path to the Python script: C:\Users\John\ProjectXFolder\ProjectXSubFolder\get_data.py
  6.  
  7. # get_data.py
  8. import os
  9. script_path = os.path.dirname(os.path.abspath(__file__))
  10. print("script_path: ", script_path)
  11. #returns
  12. C:\Users\John\ProjectXFolder\ProjectXSubFolder
  13.  
  14.  
  15. # 2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement