「Python」環境変数PATHを取得する

2021年11月24日

書式
os.get_exec_path()
環境変数PATHを取得します

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import os
# 環境PATH を取得
pathList = os.get_exec_path()
# ループで文字列のリストで返される
for pth in pathList:
print(pth)
import os # 環境PATH を取得 pathList = os.get_exec_path() # ループで文字列のリストで返される for pth in pathList: print(pth)
import os

# 環境PATH を取得
pathList = os.get_exec_path()

# ループで文字列のリストで返される
for pth in pathList:
    print(pth)

実行結果
/usr/local/bin
/usr/bin
/bin

Python

Posted by arkgame