PyCharm 调用函数 DocString 的问题

75 天前
 Insomnic
求教一下大神们,为什么我使用 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 中暂时没有找到办法。
674 次点击
所在节点    程序员
2 条回复
iYume
75 天前
IDE 识别 docstring 是靠静态分析的,而有的代码 __doc__ 往往是动态注入的,为了生成 API 文档。
Insomnic
74 天前
@iYume 所有有没有办法在 pycharm 中通过快捷键调用完整的 docstring 呢?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://yangjunhui.monster/t/1112929

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX