如何获得有关 Python 方法的帮助? [英] How to get help on methods in Python?

查看:57
本文介绍了如何获得有关 Python 方法的帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在方法上使用 help() 时,我都会得到看起来很奇怪的输出.例如,help(obj.readline) 给我以下输出:

关于内置函数 readline 的帮助:阅读线(...)

这就是我所得到的.我不知道如何解释它.为什么没有关于方法的描述?有人可以向我解释一下这是怎么回事吗?

解决方案

这是奇怪的输出吗?

<预><代码>>>>f = open('data.txt')>>>帮助(f.readline)内置函数 readline 的帮助:阅读线(...)readline([size]) ->文件的下一行,作为字符串.保留换行符.非负大小参数限制最大值要返回的字节数(然后可能会返回不完整的行).在 EOF 处返回一个空字符串.

whenever I use help() on a method I get a weird looking output. For example, help(obj.readline) gives me the following output:

Help on built-in function readline:

readline(...)

That's all i get. I don't know how to interpret it.Why there is no description about the method? Can somebody please explain to me what's going on?

解决方案

Is this weird output?

>>> f = open('data.txt')
>>> help(f.readline)
Help on built-in function readline:

readline(...)
    readline([size]) -> next line from the file, as a string.

    Retain newline.  A non-negative size argument limits the maximum
    number of bytes to return (an incomplete line may be returned then).
    Return an empty string at EOF.

这篇关于如何获得有关 Python 方法的帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆