什么是“sys.stdout.write()"?Ruby 中的等价物? [英] What is the "sys.stdout.write()" equivalent in Ruby?
本文介绍了什么是“sys.stdout.write()"?Ruby 中的等价物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如在 Python 中所见,Ruby 中的 sys.stdout.write()
等价物是什么?
As seen in Python, what is the sys.stdout.write()
equivalent in Ruby?
推荐答案
在 Ruby 中,您可以使用 $stdout
或 STDOUT
访问标准输出.所以你可以像这样使用 write 方法:
In Ruby, you can access standard out with $stdout
or STDOUT
. So you can use the write method like this:
$stdout.write 'Hello, World!'
或等效地:
STDOUT.write 'Hello, World!'
$stdout
实际上是一个全局变量,默认值为STDOUT
.
$stdout
is a actually a global variable whose default value is STDOUT
.
你也可以使用puts
,但我认为这更类似于python的print
.
You could also use puts
, but I think that is more analogous to python's print
.
这篇关于什么是“sys.stdout.write()"?Ruby 中的等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文