「Python」環境変数PATHを取得する
書式
os.get_exec_path()
環境変数PATHを取得します
使用例
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