Node.js:无需尾随换行符即可打印到控制台? [英] Node.js: printing to console without a trailing newline?

查看:145
本文介绍了Node.js:无需尾随换行符即可打印到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种无需尾随换行符即可打印到控制台的方法? console对象文档没说什么关于这一点:

Is there a method for printing to the console without a trailing newline? The console object documentation doesn't say anything regarding that:

console.log()

console.log()

使用换行符打印到标准输出.此函数可以采用类似printf()的方式接受多个参数.示例:

Prints to stdout with newline. This function can take multiple arguments in a printf()-like way. Example:

console.log('count: %d', count);

如果在第一个字符串中未找到格式设置元素,则在每个参数上使用util.inspect.

If formating elements are not found in the first string then util.inspect is used on each argument.

推荐答案

您可以使用process.stdout.write():

process.stdout.write("hello: ");

有关详细信息,请参见文档.

See the docs for details.

这篇关于Node.js:无需尾随换行符即可打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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