Чтобы получить разрешение экрана ПК с помощью Python, вы можете использовать различные методы. Вот несколько вариантов:
-
Использование библиотеки
pyautogui:import pyautogui screen_width, screen_height = pyautogui.size() print(f"Screen Resolution: {screen_width}x{screen_height}") -
Использование библиотеки
tkinter:import tkinter as tk root = tk.Tk() screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() root.destroy() print(f"Screen Resolution: {screen_width}x{screen_height}") -
Использование модуля
win32api(для Windows):import win32api screen_width = win32api.GetSystemMetrics(0) screen_height = win32api.GetSystemMetrics(1) print(f"Screen Resolution: {screen_width}x{screen_height}") -
Использование библиотеки
screeninfo:from screeninfo import get_monitors monitor = get_monitors()[0] screen_width = monitor.width screen_height = monitor.height print(f"Screen Resolution: {screen_width}x{screen_height}")