Skip to content

Instantly share code, notes, and snippets.

@heyswappy
Last active August 1, 2020 21:11
Show Gist options
  • Save heyswappy/ec195c4685ea0594e22300fd74a43532 to your computer and use it in GitHub Desktop.
Save heyswappy/ec195c4685ea0594e22300fd74a43532 to your computer and use it in GitHub Desktop.
import os # import the operating-system module
print(os.getcwd()) # print current working directory of the script
fp = open("file.ext") # open some file in the current working directory i.e. where script lives
# how does it know the location of file.ext
fp.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment