Python/サンプル/スクリプトを実行しているパス(ディレクトリ)を取得する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* Pythonスクリプトを実行しているパス(ディレクトリ)を取得...
Pythonスクリプトが実行されているパス(ディレクトリ)を取得...
#contents
#htmlinsertpcsp(ll-top.html,ll-sp.html)
* 動作確認環境 [#o9c2e844]
$ python --version
Python 2.7.3
$ lsb_release -d
Description: Ubuntu 12.04.4 LTS
* 関連記事 [#ob35a1f7]
-[[Pythonスクリプトを実行しているパス(ディレクトリ)を取得...
-[[Pythonスクリプトが存在するパス(ディレクトリ)を取得する...
-[[Pythonのスクリプト名を取得する>Python/サンプル/スクリ...
* スクリプト実行中のパス(ディレクトリ)を取得する [#acff8f...
以下のサンプルコードおよび実行結果を参照してください。
** サンプルコード [#cc565edf]
#ref(getcwd.py)
import os
cwd = os.getcwd()
print cwd
** 実行結果 [#h9e651e4]
今回実行するPythonのサンプルコードは以下のディレクトリに...
sakura@ubuntu:~$ pwd
/home/sakura
sakura@ubuntu:~$ ls -l python/getcwd.py
-rw-rw-r-- 1 sakura sakura 39 2月 24 15:46 python/getcw...
実際に実行したときの出力です。
sakura@ubuntu:~$ python python/getcwd.py
/home/sakura
スクリプトが実行されている絶対パスが表示されているのが確...
以上、Pythonスクリプトが実行されている絶対パスを取得する...
#htmlinsertpcsp(ll-btm.html,ll-sp.html)
終了行:
#navi(../)
* Pythonスクリプトを実行しているパス(ディレクトリ)を取得...
Pythonスクリプトが実行されているパス(ディレクトリ)を取得...
#contents
#htmlinsertpcsp(ll-top.html,ll-sp.html)
* 動作確認環境 [#o9c2e844]
$ python --version
Python 2.7.3
$ lsb_release -d
Description: Ubuntu 12.04.4 LTS
* 関連記事 [#ob35a1f7]
-[[Pythonスクリプトを実行しているパス(ディレクトリ)を取得...
-[[Pythonスクリプトが存在するパス(ディレクトリ)を取得する...
-[[Pythonのスクリプト名を取得する>Python/サンプル/スクリ...
* スクリプト実行中のパス(ディレクトリ)を取得する [#acff8f...
以下のサンプルコードおよび実行結果を参照してください。
** サンプルコード [#cc565edf]
#ref(getcwd.py)
import os
cwd = os.getcwd()
print cwd
** 実行結果 [#h9e651e4]
今回実行するPythonのサンプルコードは以下のディレクトリに...
sakura@ubuntu:~$ pwd
/home/sakura
sakura@ubuntu:~$ ls -l python/getcwd.py
-rw-rw-r-- 1 sakura sakura 39 2月 24 15:46 python/getcw...
実際に実行したときの出力です。
sakura@ubuntu:~$ python python/getcwd.py
/home/sakura
スクリプトが実行されている絶対パスが表示されているのが確...
以上、Pythonスクリプトが実行されている絶対パスを取得する...
#htmlinsertpcsp(ll-btm.html,ll-sp.html)
ページ名: