在ruby中的puts
语句自动添加一个新行,我该如何避免呢?
Use print
instead. You may want to follow it up by STDOUT.flush
.
此外,您需要在行尾添加“\\ r”以指示“回车”并在当前行的开头执行下一次打印
$stdout.sync = true
100.times do
print "."
sleep 1
end
"How can I use “puts” to the console without a line break in ruby on rails?"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.