【问题标题】:PyCharm Python console displaying docstrings incorrectlyPyCharm Python 控制台错误地显示文档字符串
【发布时间】:2017-07-11 04:34:49
【问题描述】:

我的 PyCharm 中的控制台打印文档不正确 - 它仍然有 \n 符号代替新行,并且只打印出一个长行。有谁知道可能是什么问题?

http://imgur.com/a/DqipY 这是我所描述的图像。

【问题讨论】:

  • 重复几天前未回答的问题:stackoverflow.com/questions/44937959/…
  • 你能提供完整的方法来复制你的问题吗?即显示您的导入和变量声明
  • @nanotek - 这没什么特别的。只是import numpy as np > ? np.array()

标签: python console ipython pycharm


【解决方案1】:

使用print 函数和__doc__ 属性来显示文档字符串。

import numpy as np
print(np.array.__doc__)

Create an array.
Parameters
----------
object : array_like
    An array, any object exposing the array interface, an object whose
    __array__ method returns an array, or any (nested) sequence.
dtype : data-type, optional
    The desired data-type for the array.  If not given, then the type will
    be determined as the minimum type required to hold the objects in the
...

【讨论】:

  • 哦,效果很好。虽然这是一种解决方法 - 能够使用 ipython 会很好吗?命令 - 谢谢!
  • 我真的不认为这是一种解决方法。您的问题是如何让文档字符串打印得很好,这就是您可以很好地查看 python 文档字符串的方法。如果您想要一个与让 ipython ? 运算符以不同方式打印内容特别相关的答案,那么最好将其包含在您的问题中。我不是 ipython 专家,但我稍微研究了一下,我找不到您正在寻找的解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-13
  • 2017-10-08
  • 2019-08-30
  • 2015-11-19
相关资源
最近更新 更多