株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

osモジュールというものがある

import os

unameコマンド結果が取れる

os.uname()
('Linux', 'ip-172-31-13-213.ap-northeast-1.compute.internal', 
'4.14.123-111.109.amzn2.x86_64', '#1 SMP Mon Jun 10 19:37:57 UTC 2019',
 'x86_64')

ホスト名だけ

os.uname()[1]
'ip-172-31-13-213.ap-northeast-1.compute.internal'

OSバージョン

os.uname()[2]
'4.14.123-111.109.amzn2.x86_64'

参考

https://qiita.com/iorionda/items/cfceac93c9e87d430077

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)