Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active September 25, 2017 23:58
Show Gist options
  • Save ZeccaLehn/fb76acb246c2507c207b3a4e5352a2f9 to your computer and use it in GitHub Desktop.
Save ZeccaLehn/fb76acb246c2507c207b3a4e5352a2f9 to your computer and use it in GitHub Desktop.
Python working directory management
import os
# Takes home path and appends working folder to path
os.chdir(os.path.expanduser('~') + '\Desktop') # Set to working folder on Desktop
print(os.getcwd()) # Returns new directory

# Returns path of home directory
os.path.expanduser('~')

os.listdir() # returns list of files in new working directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment