rubyfilewindowsc 标准输入流:gets 读文件 File.open("hello.rb","r") do |file| while line = file.gets puts line #打印出文件内容 end end 标准输出流:puts print 两者的区别是puts会在参数后面添加回车换行,print不会添加 printf("Number:%5.2f,\nString:%s\n",1.23,"hello") 这个语法跟c相同就不多说了 %5.2f 匹配 1.23 %s 匹配字符串
123
最新推荐文章于 2023-03-15 10:16:06 发布