Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

expanduser - handle tilde ~ the home directory of the user

  • expanduser
  • ~
  • os.path.expanduser
import os

# The home directory of the current user
home_directory = os.path.expanduser("~")

print(home_directory)
# /home/gabor
# 'C:\\Users\\Gabor Szabo'