Categories
Python Answers

How to get monitor resolution in Python?

Spread the love

Sometimes, we want to get monitor resolution in Python.

In this article, we’ll look at how to get monitor resolution in Python.

How to get monitor resolution in Python?

To get monitor resolution in Python, we can use the screeninfo package.

To install it, we run

pip install screeninfo

Then we use it by writing

from screeninfo import get_monitors

for m in get_monitors():
    print(str(m))

to call get_monitors to get the data for all the monitors in the system.

And then we print the values as strings with print in the loop.

Conclusion

To get monitor resolution in Python, we can use the screeninfo package.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *