How to get current directory in Python

  • Get current working directory :

import os
result = os.getcwd()
  • Get the directory of the script being run :

import os
os.path.dirname(os.path.abspath(__file__))
  • DONE!


Leave a Reply