Pylint错误:模块Pythoncom没有成员

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

我是python的新手,正在使用visual studio代码,我也安装了pywin32。但是,当我运行程序时,它说pythoncom模块没有CoInitialize和CoUninitialize成员。

我想知道如何让pythoncom识别出这两个成员?

import os

if os.name == 'nt':
   import pythoncom
class PlatformHelper: 

   def __init__(self):
       if os.name == 'nt':
           pythoncom.CoInitialize()

   def __del__(self):                
       if os.name == 'nt':
           pythoncom.CoUninitialize() 

if __name__ == "__main__":
    print ("roypy_platform_utils is a utility module, it doesn't expect to be run directly")
python pylint
1个回答
0
投票

你能尝试用--extension-pkg-whitelist=pythoncom运行pylint吗?如果pythoncom是一个C Python模块,那么pylint将很难理解它的结构,因为代码最有可能在C中。在这种情况下,当你指定该标志时,你通知pylint导入模块以便构建来自活动对象的AST,通常可以帮助解决这些错误。

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