V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Insomnic
V2EX  ›  程序员

PyCharm 调用函数 DocString 的问题

  •  
  •   Insomnic · 6 天前 · 351 次点击
    求教一下大神们,为什么我使用 ctrl+Q 快捷键调用函数的说明文档,跟使用 print(函数名称.__doc__)输出的内容会不一样?

    比如我要查看 cv2.namedWindow 的说明文档,使用 ctrl+Q 的结果:
    def namedWindow(winname: str,
    flags: int = ...) ->

    简单的不能再简单。似乎只调用了头文件???

    而使用 print(cv2.namedWindow.__doc__),就能输出完整的函数说明文档:
    namedWindow(winname[, flags]) -> None
    . @brief Creates a window.
    .
    . The function namedWindow creates a window that can be used as a placeholder for images and
    . trackbars. Created windows are referred to by their names.
    .
    . If a window with the same name already exists, the function does nothing.
    .
    . You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated

    请问一下问题在哪里?应该如何解决?

    同一个函数,在 jupyter 工具下是可以通过快捷键直接调用完整的说明文档,但在 pycharm 中暂时没有找到办法。
    iYume
        1
    iYume  
       6 天前
    IDE 识别 docstring 是靠静态分析的,而有的代码 __doc__ 往往是动态注入的,为了生成 API 文档。
    Insomnic
        2
    Insomnic  
    OP
       5 天前
    @iYume 所有有没有办法在 pycharm 中通过快捷键调用完整的 docstring 呢?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5669 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 06:17 · PVG 14:17 · LAX 22:17 · JFK 01:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.