Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这个python脚本的ruby等价物是什么?_Python_Ruby On Rails_Ruby - Fatal编程技术网

这个python脚本的ruby等价物是什么?

这个python脚本的ruby等价物是什么?,python,ruby-on-rails,ruby,Python,Ruby On Rails,Ruby,print({0:5s}{1:7s}{2:9s}{3:6s}{4:25s}{5:s})。格式('Rank','Points','Comments','Hours','Sub','Link')) 对于结果中的ent: 打印({0:5s}{1:7s}{2:9s}{3:6s}{4:25s}{5:s})。格式(str(ent[0]),str(ent[1]),str(ent[2]),str(round(ent[3],2)),str(ent[4]),str(ent[5])Python: print ("{0

print({0:5s}{1:7s}{2:9s}{3:6s}{4:25s}{5:s})。格式('Rank','Points','Comments','Hours','Sub','Link'))
对于结果中的ent:
打印({0:5s}{1:7s}{2:9s}{3:6s}{4:25s}{5:s})。格式(str(ent[0]),str(ent[1]),str(ent[2]),str(round(ent[3],2)),str(ent[4]),str(ent[5])
Python:

print ("{0:5s} {1:7s} {2:9s} {3:6s} {4:25s} {5:s}".format('Rank', 'Points', 'Comments', 'Hours', 'Sub', 'Link'))
红宝石:

或者:

puts sprintf("%-5s %-7s %-9s %-6s %-25s %-5s", *['Rank', 'Points', 'Comments', 'Hours', 'Sub', 'Link'])

我在这个问题上遭到了很多反对票,所以也许我问错了问题,但我一直在寻找一种基本上用ruby在专栏中打印的方法。这被否决的原因有两个(我能想到):a)缺乏已证明的尝试b)Python社区不愿意帮助将Python翻译成Ruby,反之亦然。请看:如果您展示一些示例输入数据和结果输出,我认为这个问题可以解决:那么了解Ruby的人可以帮助您,而不必了解Python。这对我帮助很大!我还在学习,所以这个比较真的很有帮助
puts sprintf("%-5s %-7s %-9s %-6s %-25s %-5s", *['Rank', 'Points', 'Comments', 'Hours', 'Sub', 'Link'])