What is a cross-platform way to get the home directory?

You want to use os.path.expanduser.
This will ensure it works on all platforms:

from os.path import expanduser
home = expanduser("~")

If you’re on Python 3.5+ you can use pathlib.Path.home():

from pathlib import Path
home = str(Path.home())

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)