node.js 是否有等效的 sprintf [英] Is there a sprintf equivalent for node.js

查看:34
本文介绍了node.js 是否有等效的 sprintf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望在 node.js 中进行输出格式化(sprintf 类型功能),但在我自己编写之前,我想知道是否有类似的内置内容(我已经搜索了文档但无济于事)或者是否有人已经编写了一个模块.

Looking to do output formatting (sprintf type functionality) in node.js, but before I write it myself I was wondering if there's something similar built-in (I've trawled the docs to no avail) or if someone's already written a module.

非常感谢

推荐答案

util.format().

There is now printf-like support in util.format().

示例:

util.format('hello %s', 'world');
// Returns: 'hello world'

这篇关于node.js 是否有等效的 sprintf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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