Categories

Dec 22, 2019 in Python
Q: What’s The Process To Get The Home Directory Using ‘~’ In Python?

1 Answer

Dec 22, 2019
You need to import the os module, and then just a single line would do the rest.

import os

print (os.path.expanduser('~'))

Output:

/home/runner
Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Jun 24 in Python
Feb 21
Jun 24 in Python
...