【问题标题】:Julia equivalent of Python's "help()"Julia 相当于 Python 的“help()”
【发布时间】:2019-06-11 08:40:10
【问题描述】:

在python中获取函数的文档,我们可以输入(例如)help(len)

如何在 Julia 中获取函数的文档?

【问题讨论】:

    标签: julia


    【解决方案1】:

    在 Julia 中,您可以使用问号后跟函数名称,即?functionname,来获取有关函数的信息。

    如果您使用the REPL,问号会将您的julia> 提示切换为help?> 提示 - 类似于] 如何触发pkg> REPL 模式。查看documentation了解更多信息。

    在 Jupyter 笔记本 (IJulia) 中,您只需键入 ?println,并没有可见的 REPL 模式更改。

    例子:

    help?> println # I typed ?println
    search: println printstyled print sprint isprint
    
      println([io::IO], xs...)
    
      Print (using print) xs followed by a newline. If io is not supplied, prints to stdout.
    
      Examples
      ≡≡≡≡≡≡≡≡≡≡
    
      julia> println("Hello, world")
      Hello, world
    
      julia> io = IOBuffer();
    
      julia> println(io, "Hello, world")
    
      julia> String(take!(io))
      "Hello, world\n"
    

    请注意,这种方法不限于函数。它适用于所有附加了一些文档字符串的对象:

    help?> Sys.CPU_THREADS # docstring of a constant
      Sys.CPU_THREADS
    
      The number of logical CPU cores available in the system, i.e. the number of threads that the CPU can run concurrently. Note that this is not necessarily the number of CPU cores, for example, in the presence of hyper-threading (https://en.wikipedia.org/wiki/Hyper-threading).
    
      See Hwloc.jl or CpuId.jl for extended information, including number of physical cores.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-19
      • 2020-12-04
      • 2018-06-24
      • 2013-11-14
      • 2021-09-14
      • 2019-02-05
      • 2015-05-17
      • 1970-01-01
      相关资源
      最近更新 更多