LoginSignup
27

More than 3 years have passed since last update.

posted at

updated at

pythonでホームディレクトリの取得

よく忘れるのでメモ

home_directory.py
import os
print os.environ['HOME']

追記

winにも対応するなら

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

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
27