--- lang: ja-jp breaks: true --- # Python スクリプトの絶対パスを取得 2021-07-23 ```python= import os scriptPath = os.path.dirname(os.path.abspath(__file__)) print('script path: ', scriptPath) ``` :::info パスの末尾に区切り文字はありません。 ::: :::warning `os.getcwd()`では正しく取得できません。 ::: ###### tags: `Python` `スクリプト` `絶対パス`