0

is there anyway to get model name of cpu using python ?

I have code which gives model name in Linux but i want model name in windows.

code:

with open('/proc/cpuinfo') as f:
    for line in f:
       # Ignore the blank line separating the information between
       # details about two processing units
       if line.strip():
           if line.rstrip('\n').startswith('model name'):
               model_name = line.rstrip('\n').split(':')[1]
               model=model_name
               model=model.strip()
               break
print(model)

please help me ?

python_fan
  • 113
  • 2
  • 15

1 Answers1

0

The platform.processor() function returns the processor name as a string.

>>> import platform
>>> platform.processor()
'Intel64 Family 6 Model 23 Stepping 6, GenuineIntel'
maguri
  • 386
  • 2
  • 10
  • Same here: https://stackoverflow.com/questions/4842448/getting-processor-information-in-python – maguri Dec 19 '17 at 12:12
  • (not the downvoter, but) If you're repeating an answer from an identical question, what you should instead do is flag the question as a duplicate so it can be closed, rather than answer it. – cs95 Dec 19 '17 at 12:14
  • Sorry, new on this – maguri Dec 19 '17 at 13:58