puts 在屏幕上输出指定的字符串,并以回车结束
print 和puts的功能一样,不以回车结束
printf 格式化输出,类似C语言和Java
puts "puts works" puts " with line breaks." print "print works" print " with no line breaks." printf("\n\nprintf formats numbers like %7.2f, and strings like %s.",3.14156,"me")
输出结果如下
puts works with line breaks. print works with no line breaks. printf formats numbers like 3.14, and strings like me.