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

您的位置:首頁技術文章
文章詳情頁

python利用platform模塊獲取系統信息

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

Python platform 模塊

platform 模塊用于查看當前操作系統的信息,來采集系統版本位數計算機類型名稱內核等一系列信息。

使用方法:

#coding:utf-8import platformt=platform.system()print(t)#coding=utf-8#platform_mode.pyimport platform’’’ python中,platform模塊給我們提供了很多方法去獲取操作系統的信息 如: import platform platform.platform() #獲取操作系統名稱及版本號,’Linux-3.13.0-46-generic-i686-with-Deepin-2014.2-trusty’ platform.version() #獲取操作系統版本號,’#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015’ platform.architecture() #獲取操作系統的位數,(’32bit’, ’ELF’) platform.machine() #計算機類型,’i686’ platform.node() #計算機的網絡名稱,’XF654’ platform.processor() #計算機處理器信息,’’i686’ platform.uname() #包含上面所有的信息匯總,(’Linux’, ’XF654’, ’3.13.0-46-generic’, ’#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015’, ’i686’, ’i686’) 還可以獲得計算機中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(): ’’’獲取操作系統名稱及版本號’’’ return platform.platform()def get_version(): ’’’獲取操作系統版本號’’’ return platform.version()def get_architecture(): ’’’獲取操作系統的位數’’’ return platform.architecture()def get_machine(): ’’’計算機類型’’’ return platform.machine()def get_node(): ’’’計算機的網絡名稱’’’ return platform.node()def get_processor(): ’’’計算機處理器信息’’’ return platform.processor()def get_system(): ’’’獲取操作系統類型’’’ 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(’獲取操作系統名稱及版本號 : [{}]’.format(get_platform())) print(’獲取操作系統版本號 : [{}]’.format(get_version())) print(’獲取操作系統的位數 : [{}]’.format(get_architecture())) print(’計算機類型 : [{}]’.format(get_machine())) print(’計算機的網絡名稱 : [{}]’.format(get_node())) print(’計算機處理器信息 : [{}]’.format(get_processor())) print(’獲取操作系統類型 : [{}]’.format(get_system())) print(’匯總信息 : [{}]’.format(get_uname()))def show_os_info(): ’’’只打印os的信息,沒有解釋部分’’’ 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的信息,沒有解釋部分’’’ 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(’操作系統信息:’) if SHOW_LOG: show_os_all_info() else: show_os_info() print(’#’ * 50) print(’計算機中的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操作系統信息:獲取操作系統名稱及版本號 : [Windows-7-6.1.7601-SP1]獲取操作系統版本號 : [6.1.7601]獲取操作系統的位數 : [(’32bit’, ’WindowsPE’)]計算機類型 : [AMD64]計算機的網絡名稱 : [dw2019]計算機處理器信息 : [Intel64 Family 6 Model 69 Stepping 1, GenuineIntel]獲取操作系統類型 : [Windows]匯總信息 : [uname_result(system=’Windows’, node=’dw2019’, release=’7’, version=’6.1.7601’, machine=’AMD64’, processor=’Intel64 Family 6 Model 69 Stepping 1, GenuineIntel’)]##################################################計算機中的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模塊獲取系統信息的詳細內容,更多關于Python platform 模塊的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 午夜色大片在线观看 | 国产超级乱淫视频播放 | 国产黄的网站免费 | 国产成人a大片大片在线播放 | 久久在线免费观看视频 | 久久青青草原国产精品免费 | 日本aaaa级毛片在线看 | 黄色爱爱视频 | 成人入口 | 丝袜美腿亚洲综合 | 一级免费黄色毛片 | 亚洲精品国产网红在线 | 精品日韩欧美 | 污污免费网站 | 正在播放亚洲一区 | 亚洲欧美在线中文字幕不卡 | 国产成人网| 亚洲国产欧美在线 | 久青草视频在线播放 | 亚洲精品系列 | 国产成人精品区在线观看 | 91福利视频免费 | 精品一二 | 9久re在线观看视频精品 | 成人激情视频在线观看 | 一级a做爰片欧欧美毛片4 | 国产成人在线网址 | 99久久精品国产综合一区 | 精品欧美激情在线看 | 91刘亦菲精品福利在线 | chinese国产videos国产 | 欧美国产小视频 | 视频二区在线观看 | 爱爱小视频在线观看网站 | 女人被狂躁的免费视频网站软件 | 又亲又揉摸下面视频免费看 | 青青草手机在线观看 | 91久久国产露脸精品免费 | 国产欧美日韩精品第二区 | 看片在线观看 | 免费黄色欧美视频 |