python으로 컴퓨터 사양 알아내기

조회수 3921회

python 으로 컴퓨터 사양을 알아내고 싶습니다. 예를 들어

  1. CPU 개수
  2. CPU 종류
  3. RAM 용량 .....

방법을 알 수 있을까요?

  • 사용하는 os가 뭔가요? 정영훈 2017.5.24 00:04

1 답변

  • 좋아요

    2

    싫어요
    채택 취소하기

    cpu 갯수, cpu 종류 ram 용량 정도는 기본 라이브러리로 커버가 됩니다만 좀 더 세부적인 시스템 정보는 네이티브 라이브러리를 사용해야 될 수 있습니다.

    platform 모듈을 확인해보세요. https://docs.python.org/3/library/platform.html

    psutil 모듈도 참고하세요. https://github.com/giampaolo/psutil

    import platform
    
    platform.machine()
    Out[3]: 'x86_64'
    
    platform.version()
    Out[4]: '#99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017'
    
    platform.platform()
    Out[5]: 'Linux-4.4.0-78-generic-x86_64-with-LinuxMint-18.1-serena'
    
    platform.uname()
    Out[6]: uname_result(system='Linux', node='allinux-note', release='4.4.0-78-generic', version='#99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017', machine='x86_64', processor='x86_64')
    
    platform.system()
    Out[7]: 'Linux'
    
    platform.processor()
    Out[8]: 'x86_64'
    
    import os
    
    print(str(os.popen('free -t -m').readlines()))
    ['              total        used        free      shared  buff/cache   available\n', 'Mem:           7901        1128        4534         409        2239        6017\n', 'Swap:          9535           0        9535\n', 'Total:        17437        1128       14070\n']
    

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)