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'
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
import os
# The home directory of the current user
home_directory = os.path.expanduser("~")
print(home_directory)
# /home/gabor
# 'C:\\Users\\Gabor Szabo'