【问题标题】:Pylint error: Module Pythoncom has no memberPylint 错误:模块 Pythoncom 没有成员
【发布时间】:2018-11-25 06:37:23
【问题描述】:

我是 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】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多