Extracting information with Python

Asked

Viewed 232 times

-1

I’m conducting some tests with Python and would like to extract some data that are presented on the page of "System information" in the Windows.

I know the library "os" of Python allows us to execute processes like this, which is the msinfo32.

I would like some guidance on how to extract data from, for example, the field "Processor" and "Product Baseboard". What would be the best resources or libraries to send this information as a string, for example?

I’m using Python 3.7.2

1 answer

1


You can use the library platform to get this information from the system.

>>> import platform
>>> platform.machine()
'x86'
>>> platform.version()
'5.1.2600'
>>> platform.platform()
'Windows-XP-5.1.2600-SP2'
>>> platform.uname()
('Windows', 'name', 'XP', '5.1.2600', 'x86', 'x86 Family 6 Model 15 Stepping 6, GenuineIntel')
>>> platform.system()
'Windows'
>>> platform.processor()
'x86 Family 6 Model 15 Stepping 6, GenuineIntel'

In the documentation you will find more information about her.

If you need information about processes and system usage, you also have the library psutil.

>>> import psutil
>>> psutil.cpu_count()
4

Again, you will find more details on documentation.

You can also use the library os for other system information you can get from the command line. Test:

import os
for line in os.popen('systeminfo'): print(line.rstrip())
  • I had already done some tests with this library as well, but if I needed specifically the information contained in msinfo32, there would be some way?

  • You have information that you can get with a systeminfo. I’ll put in the answer. If you need something more specific, tell us what we can help you with.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.