【问题标题】:How to get help on methods in Python? (Again...)如何获得 Python 中方法的帮助? (再次...)
【发布时间】:2020-11-16 13:49:47
【问题描述】:

我再次发布这个问题,略有不同。

How to get help on methods in Python?

我主要使用 Jupyter Lab。

我主要处理数字...但有时我也需要管理字符串...而且我需要回忆如何使用一些方法。所以,我需要上网去论坛或在我的笔记本上搜索,看看我是怎么做到的……

有没有办法使用“帮助”获取包含可用于对象的内置方法列表的文档字符串?还是“?”?

和,

有没有办法在不为此创建对象的情况下获得有关方法的帮助?喜欢

x = 'x'
x.split?

谢谢

【问题讨论】:

  • help(str.split) 或阅读respective part of the docs
  • 谢谢。 str.split? 在 Jupyter 中做同样的事情。问题是还有其他方法吗?以及如何在“内部”获得更完整的文档......

标签: python methods documentation


【解决方案1】:

python帮助功能用于显示模块、函数、类、关键字等的文档。 帮助函数的语法如下:

help([object])

如果传递帮助函数时不带参数,则交互式帮助实用程序会在控制台上启动。

x="ab"
help(x.split)
Help on built-in function split:

split(...) method of builtins.str instance
    S.split(sep=None, maxsplit=-1) -> list of strings
    
    Return a list of the words in S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string is a separator and empty strings are
    removed from the result.

官方文档:Documentation

【讨论】:

  • 谢谢。我的问题是关于无需离开 Jupyter 即可访问文档......或者当我无法访问互联网时!
猜你喜欢
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-10
  • 1970-01-01
  • 2016-06-22
相关资源
最近更新 更多