In [34]: hoge = !echo $PATHIn [35]: hoge[0].split(':')Out[35]:['/Users/Ishinaga/anaconda/bin','/usr/local/Cellar/pyenv-virtualenv/20160202/shims','/usr/local/Cellar/pyenv/20160726/libexec','/Users/Ishinaga/.pyenv/shims','/Users/Ishinaga/.pyenv/bin','/usr/local/bin','/Users/Ishinaga/.rbenv/shims','/Applications/apache-ant-1.9.4/bin','/Applications/android-ndk-r9d','/Applications/cocos2d-x-3.4/templates','/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools','/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools','/Applications/adt-bundle-mac-x86_64-20140321/sdk','/Applications/cocos2d-x-3.4/tools/cocos2d-console/bin','/usr/local/bin','/usr/bin','/bin','/usr/sbin','/sbin','/opt/X11/bin','/Users/Ishinaga/ImageMagick-6.7.5/bin','/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools','/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools','/Applications/android-ndk-r9d']In [36]:
コロン区切りの文字列をsplitで分割しただけだがね。連結されてると醜いので。
!でコマンドを実行できるけど、これはipython上だけなので注意。
!の結果は IPython.utils. text.SList のオブジェクトで、[0]してやるとtextになる、みたい。
0 件のコメント:
コメントを投稿