Get home directory with python

I often forget it, so make a note

home_directory.py


import os
print os.environ['HOME']

Postscript

If it also supports win

from os.path import expanduser
home = expanduser("~")

Reference: https://stackoverflow.com/questions/4028904/how-to-get-the-home-directory-in-python

Recommended Posts

Get home directory with python
Get date with python
Get country code with python
Get Twitter timeline with python
Get Youtube data with python
Get thread ID with python
Get started with Python! ~ ② Grammar ~
Get stock price with Python
Create a directory with python
Get keyboard events with python
Get Alembic information with Python
Get started with Python! ~ ① Environment construction ~
Link to get started with python
Get reviews with python googlemap api
Get the weather with Python requests
Get web screen capture with python
Get the weather with Python requests 2
[Python] Get economic data with DataReader
How to get started with Python
[Small story] Get timestamp with Python
Get Qiita trends with Python scraping
Get started with Python in Blender
Get weather information with Python & scraping
[Python] Get the script execution directory with an absolute path
Get additional data in LDAP with python
Get property information by scraping with python
FizzBuzz with Python3
Get html from element with Python selenium
Scraping with Python
[Note] Get data from PostgreSQL with Python
Statistics with python
Scraping with Python
[Python] Get the variable name with str
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
python starts with ()
Get Started with TopCoder in Python (2020 Edition)
Bingo with python
Zundokokiyoshi with python
[Python] Get Python package information with PyPI API
How Python beginners get started with Python with Progete
Let's get along with Python # 0 (Environment construction)
Excel with Python
Microcomputer with Python
[Blender x Python] Let's get started with Blender Python !!
Cast with python
Python hand play (let's get started with AtCoder?)
[Python] Get the files in a folder with Python
Get a ticket for a theme park with python
Get stock price data with Quandl API [Python]
I tried to get CloudWatch data with Python
Get git branch name and tag name with python
[Python] Get rid of dating with regular expressions
I want to use Temporary Directory with Python2
[python] [vscode] When you get angry with space-tab-mixed
Get CPU information of Raspberry Pi with Python
Get started with Python on macOS Big Sur
Archive and compress the entire directory with python
Get Gmail subject and body with Python and Gmail API