python gets the current user's home directory path method of recommended
- 2020-05-24 05:43:35
- OfStack
Python gets the current user's home directory path, and the sample code is as follows:
#! /usr/bin/python
# -*- coding: utf-8 -*-
import os
print os.environ['HOME']
print os.path.expandvars('$HOME')
print os.path.expanduser('~')