解决Visual Studio代码中Python脚本自动调试中的错误

问题描述 投票:0回答:1

我有一个有效的Python脚本,它通过以下代码捕获主监视器工作区的宽度和高度。

# First, install library win32api by executing as administrator
# the command "pip install pywin32" in PowerShell. Then,

from win32api import MonitorFromPoint, GetMonitorInfo
handle_for_primary_monitor = MonitorFromPoint((0,0))
monitor_info = GetMonitorInfo(handle_for_primary_monitor)
work_area = monitor_info.get("Work")
width_of_work_area = work_area[2]
height_of_work_area = work_area[3]

Visual Studio代码错误地引发了以下两个错误:

Error_in_Automatic_Debugging_of_Python_Script_in_VSCode

我如何获得Visual Studio Code以识别类MonitorFromPoint和方法GetMonitorInfo实际上在win32api库中?

winapi visual-studio-code pywin32 python-3.8
1个回答
0
投票
实际上,Pylint在分析期间不会运行Python代码,因此大多数非标准(不可推断)的构造都必须通过编写自定义代码来支持。

参考:Why is pylint unable to find this package's module(s)?

有两种方法可以解决此问题:

© www.soinside.com 2019 - 2024. All rights reserved.