coding180 icon
Coding180

What is the process of using ~ get home directory in Python?

Home > Interviews > Python


robort - 2022-08-29 15:53:32

os The module needs to be imported, and then just one line does the rest.

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

The results are as follows:

/home/runner

user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel