We gonna need the platform module here: print("="*40, "System Information", "="*40) Let's make a function that converts a large number of bytes into a scaled format (e.g in kilo, mega, Giga, etc.): def get_size(bytes, suffix="B"):įor unit in : Open up a new Python file and let's get started, importing the necessary modules: import psutil Related: How to Manipulate IP Addresses in Python using ipaddress Module.īefore we dive in, you need to install psutil: pip3 install psutil Here is the table of content of this tutorial: However, we'll be using the psutil library in Python so it can run on all operating systems and get almost identical results. There are quite popular tools to extract system and hardware information in Linux, such as lshw, uname and hostnamectl. In the end, I'll show you how you can print GPU information (if you have one, of course) as well. In this tutorial, you will be familiar with psutil which is a c ross-platform library for process and system monitoring in Python, as well as the built-in platform module to extract your system and hardware information in Python. Give it a go!ĭisclosure: This post may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.Īs a Python developer, it is handy to use third-party libraries that do the job you actually want, instead of reinventing the wheel each time. Struggling with multiple programming languages? No worries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |