0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonで環境変数を扱う

Posted at

Pythonのコード内で環境変数を扱う方法。

import os

取得

一括取得

os.environ

環境変数名を指定して取得 os.environ[環境変数名]

# 例
os.environ['PATH']

設定

この方法で設定した場合、そのPythonプログラムの中でのみ有効。システムの環境変数は書き変わらない

# os.environ[環境変数名] = パス
os.environ['NEW_KEY'] = 'test'
0
2
0

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
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?