python - Ruby 相当于 Python 的 help()?

标签 python ruby

在交互式 Python 中工作时,我倾向于依靠内置的 help() 函数来告诉我期望和/或返回什么,并打印出任何可能对我有帮助的文档。是否有与此功能等效的 Ruby?

我正在寻找可以在 irb 中使用的东西。例如,在交互式 Python 中,我可以输入:

>>> help(1)

然后打印出来

Help on int object:

class int(object)  |  int(x[, base])
-> integer  |    |  

Convert a string or number to an integer, if possible. A ...

最佳答案

现在是 2014 年末,这里有两种获得 Python help() *相似性的方法,只要你有 Ruby Docs已安装:

  1. irb 内部,您可以调用 help 方法并使用描述您要查找的内容的字符串。

    示例 1:help 'Array' 用于 Array 类
    示例 2: help 'Array#each' 用于 Arrayeach 方法。

  2. 从命令行,irb之外,你可以使用ri程序:

    示例 1:ri 'Array' 用于 Array 类
    示例 2:ri 'Array#each' 用于 Arrayeach 方法。

* 不如 Python,但总比没有好

关于python - Ruby 相当于 Python 的 help()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2009730/

相关文章:

python - 我如何抓取输入字符串的某些部分?

python - 在 python 中使用正则表达式返回唯一匹配项

python - 如何在 Heroku 上升级 Python 项目中的依赖项

javascript - 如何通过单击 View 中的按钮来调用 Rails 中的 PLSQL 函数?

ruby-on-rails - 如何根据多对多相关模型的属性查找记录?

python - 如何向散点图添加图例?

Python 列表、csv、去重

ruby-on-rails - rails : Difference between timezones in hours

ruby - 从数组中删除空格、制表符和新行

ruby-on-rails - 在 ruby​​ 中以任意 gmt 偏移量解析时间