如何获得Python中方法的帮助?(再次…)

2024-05-09 01:00:05 发布

您现在位置:Python中文网/ 问答频道 /正文

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

How to get help on methods in Python?

我主要使用Jupyter实验室

我的工作主要是数字。。。但有时我也需要管理字符串。。。我需要回忆一下如何使用一些方法。所以,我需要上网到论坛或在我的笔记本上搜索,看看我是如何做到这一点和那一点的

有没有一种方法可以使用“帮助”获取包含对象可用的内置方法列表的docstring?还是“?”

以及

有没有一种方法可以在不创建对象的情况下获得方法的帮助?像

x = 'x'
x.split?

谢谢


Tags: to对象方法字符串ingetonhelp
1条回答
网友
1楼 · 发布于 2024-05-09 01:00:05

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.

Official Docs: Documentation

相关问题 更多 >