Python Developer Question:
Download Job Interview Questions and Answers PDF
Tell me what’s The Process To Get The Home Directory Using ‘~’ In Python?
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
import os
print (os.path.expanduser('~'))
Output:
/home/runner
Download Python Developer Interview Questions And Answers
PDF