Last updated 12 months ago
You want to use .
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 :
from pathlib import Path home = str(Path.home())
But it's usually better not to convert Path.home() to string. It's more natural to use this way:
Path.home()
with open(Path.home() / ".ssh" / "known_hosts") as f: lines = f.readlines()