Python Developer Question:

Download Job Interview Questions and Answers PDF

Tell me what’s The Process To Get The Home Directory Using ‘~’ In Python?

Python Developer Interview Question
Python Developer Interview Question

Answer:

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

Download Python Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Please write A Reg Expression That Confirms An Email Id Using The Python Reg Expression Module <Re>?Explain me what Is A Built-In Function That Python Uses To Iterate Over A Number Sequence?