亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python利用platform模塊獲取系統(tǒng)信息

瀏覽:16日期:2022-07-09 08:05:14

Python platform 模塊

platform 模塊用于查看當(dāng)前操作系統(tǒng)的信息,來(lái)采集系統(tǒng)版本位數(shù)計(jì)算機(jī)類(lèi)型名稱內(nèi)核等一系列信息。

使用方法:

#coding:utf-8import platformt=platform.system()print(t)#coding=utf-8#platform_mode.pyimport platform’’’ python中,platform模塊給我們提供了很多方法去獲取操作系統(tǒng)的信息 如: import platform platform.platform() #獲取操作系統(tǒng)名稱及版本號(hào),’Linux-3.13.0-46-generic-i686-with-Deepin-2014.2-trusty’ platform.version() #獲取操作系統(tǒng)版本號(hào),’#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015’ platform.architecture() #獲取操作系統(tǒng)的位數(shù),(’32bit’, ’ELF’) platform.machine() #計(jì)算機(jī)類(lèi)型,’i686’ platform.node() #計(jì)算機(jī)的網(wǎng)絡(luò)名稱,’XF654’ platform.processor() #計(jì)算機(jī)處理器信息,’’i686’ platform.uname() #包含上面所有的信息匯總,(’Linux’, ’XF654’, ’3.13.0-46-generic’, ’#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015’, ’i686’, ’i686’) 還可以獲得計(jì)算機(jī)中python的一些信息: import platform platform.python_build() platform.python_compiler() platform.python_branch() platform.python_implementation() platform.python_revision() platform.python_version() platform.python_version_tuple()’’’#global var#是否顯示日志信息SHOW_LOG = Truedef get_platform(): ’’’獲取操作系統(tǒng)名稱及版本號(hào)’’’ return platform.platform()def get_version(): ’’’獲取操作系統(tǒng)版本號(hào)’’’ return platform.version()def get_architecture(): ’’’獲取操作系統(tǒng)的位數(shù)’’’ return platform.architecture()def get_machine(): ’’’計(jì)算機(jī)類(lèi)型’’’ return platform.machine()def get_node(): ’’’計(jì)算機(jī)的網(wǎng)絡(luò)名稱’’’ return platform.node()def get_processor(): ’’’計(jì)算機(jī)處理器信息’’’ return platform.processor()def get_system(): ’’’獲取操作系統(tǒng)類(lèi)型’’’ return platform.system()def get_uname(): ’’’匯總信息’’’ return platform.uname()def get_python_build(): ’’’ the Python build number and date as strings’’’ return platform.python_build()def get_python_compiler(): ’’’Returns a string identifying the compiler used for compiling Python’’’ return platform.python_compiler()def get_python_branch(): ’’’Returns a string identifying the Python implementation SCM branch’’’ return platform.python_branch()def get_python_implementation(): ’’’Returns a string identifying the Python implementation. Possible return values are: ‘CPython’, ‘IronPython’, ‘Jython’, ‘PyPy’.’’’ return platform.python_implementation()def get_python_version(): ’’’Returns the Python version as string ’major.minor.patchlevel’ ’’’ return platform.python_version()def get_python_revision(): ’’’Returns a string identifying the Python implementation SCM revision.’’’ return platform.python_revision()def get_python_version_tuple(): ’’’Returns the Python version as tuple (major, minor, patchlevel) of strings’’’ return platform.python_version_tuple()def show_os_all_info(): ’’’打印os的全部信息’’’ print(’獲取操作系統(tǒng)名稱及版本號(hào) : [{}]’.format(get_platform())) print(’獲取操作系統(tǒng)版本號(hào) : [{}]’.format(get_version())) print(’獲取操作系統(tǒng)的位數(shù) : [{}]’.format(get_architecture())) print(’計(jì)算機(jī)類(lèi)型 : [{}]’.format(get_machine())) print(’計(jì)算機(jī)的網(wǎng)絡(luò)名稱 : [{}]’.format(get_node())) print(’計(jì)算機(jī)處理器信息 : [{}]’.format(get_processor())) print(’獲取操作系統(tǒng)類(lèi)型 : [{}]’.format(get_system())) print(’匯總信息 : [{}]’.format(get_uname()))def show_os_info(): ’’’只打印os的信息,沒(méi)有解釋部分’’’ print(get_platform()) print(get_version()) print(get_architecture()) print(get_machine()) print(get_node()) print(get_processor()) print(get_system()) print(get_uname())def show_python_all_info(): ’’’打印python的全部信息’’’ print(’The Python build number and date as strings : [{}]’.format(get_python_build())) print(’Returns a string identifying the compiler used for compiling Python : [{}]’.format(get_python_compiler())) print(’Returns a string identifying the Python implementation SCM branch : [{}]’.format(get_python_branch())) print(’Returns a string identifying the Python implementation : [{}]’.format(get_python_implementation())) print(’The version of Python : [{}]’.format(get_python_version())) print(’Python implementation SCM revision : [{}]’.format(get_python_revision())) print(’Python version as tuple : [{}]’.format(get_python_version_tuple()))def show_python_info(): ’’’只打印python的信息,沒(méi)有解釋部分’’’ print(get_python_build()) print(get_python_compiler()) print(get_python_branch()) print(get_python_implementation()) print(get_python_version()) print(get_python_revision()) print(get_python_version_tuple())def test(): print(’操作系統(tǒng)信息:’) if SHOW_LOG: show_os_all_info() else: show_os_info() print(’#’ * 50) print(’計(jì)算機(jī)中的python信息:’) if SHOW_LOG: show_python_all_info() else: show_python_info()def init(): global SHOW_LOG SHOW_LOG = Truedef main(): init() test()if __name__ == ’__main__’: main()

Windows操作系統(tǒng)信息:獲取操作系統(tǒng)名稱及版本號(hào) : [Windows-7-6.1.7601-SP1]獲取操作系統(tǒng)版本號(hào) : [6.1.7601]獲取操作系統(tǒng)的位數(shù) : [(’32bit’, ’WindowsPE’)]計(jì)算機(jī)類(lèi)型 : [AMD64]計(jì)算機(jī)的網(wǎng)絡(luò)名稱 : [dw2019]計(jì)算機(jī)處理器信息 : [Intel64 Family 6 Model 69 Stepping 1, GenuineIntel]獲取操作系統(tǒng)類(lèi)型 : [Windows]匯總信息 : [uname_result(system=’Windows’, node=’dw2019’, release=’7’, version=’6.1.7601’, machine=’AMD64’, processor=’Intel64 Family 6 Model 69 Stepping 1, GenuineIntel’)]##################################################計(jì)算機(jī)中的python信息:The Python build number and date as strings : [(’v3.3.3:c3896275c0f6’, ’Nov 18 2013 21:18:40’)]Returns a string identifying the compiler used for compiling Python : [MSC v.1600 32 bit (Intel)]Returns a string identifying the Python implementation SCM branch : [v3.3.3]Returns a string identifying the Python implementation : [CPython]The version of Python : [3.3.3]Python implementation SCM revision : [c3896275c0f6]Python version as tuple : [(’3’, ’3’, ’3’)]

以上就是python利用platform模塊獲取系統(tǒng)信息的詳細(xì)內(nèi)容,更多關(guān)于Python platform 模塊的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 超级香蕉97在线观看视频 | 国产精品三级在线观看 | 精品福利视频在线观看 | 黄页网站 播放器 日本 | 丁香激情综合网 | 美国一级毛片在线观看 | 伊人久久狼人 | 伊人色综合久久天天网蜜月 | 日韩精品另类天天更新影院 | xxxporn日本护士24 | 中文字幕毛片 | 欧美日韩第三页 | 日本高清xxx免费视频 | 日本一级爽毛片在线看 | 2021最新国产成人精品免费 | 免费观看黄色在线视频 | 中文字幕在线永久视频 | a一级爱做片免费 | 国产一级性生活 | 美女巨胸喷奶水gif放肆吧 | 国产免费看视频 | 秘书上班和老板啪啪中文字幕 | 欧美猛妇色xxxxxbbbb | 久久97精品久久久久久清纯 | 97超在线视频 | 九九香蕉视频 | 国产伦码精品一区二区三区 | 亚洲精品国产第一区二区尤物 | 一级 黄 色 毛片 | 最新看片网址 | 国产在线精品一区二区 | 香蕉视频在线观看黄 | 91在线精品免费观看 | 久久综合九色综合97飘花 | 国产逼逼 | 久久精品道一区二区三区 | 亚洲国产成人成上人色 | 亚洲第一大网站 | 久草在线观看首页 | 91午夜精品亚洲一区二区三区 | 狠狠色婷婷丁香综合久久韩国 |