【问题标题】:Equivalent function to sscanf in VlangVlang 中 sscanf 的等效函数
【发布时间】:2022-02-06 18:54:47
【问题描述】:

标题说明了一切;在 vlang 中寻找 sscanf 的等价物。

Go(类似于 Vlang),有 fmt.sscanf;但我在 Vlang 文档中没有看到任何类似的内容。

我能找到的最接近的方法是find_between;但是如果我有很多元素要从字符串中拉出,我就不得不连续调用它。

【问题讨论】:

  • 为什么要表现sscanf函数是你可以使用下面的语法'$var_q:$var_e'?

标签: vlang


【解决方案1】:

在 V 中不需要这种类型的函数,因为您可以使用以下语法 '$var_q:$var_e' 格式化字符串

这是v编译器的真实代码示例

fn run_repl(workdir string, vrepl_prefix string) {
    if !is_stdin_a_pipe {
        println(version.full_v_version(false))
        println('Use Ctrl-C or ${term.highlight_command('exit')} to exit, or ${term.highlight_command('help')} to see other available commands')
    }
// .. other repl code
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    • 2019-11-18
    • 2021-12-02
    • 2018-08-06
    • 2016-01-23
    相关资源
    最近更新 更多