如何在输出中进行换行 [英] How to do a newline in output

查看:158
本文介绍了如何在输出中进行换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使\n在输出中实际起作用?目前,它只是将其全部写入1个长块中.感谢您的帮助

How do I make \n actually work in my output? At the moment it just writes it all in 1 long block. Thanks for any help

Dir.chdir 'C:/Users/name/Music'
music = Dir['C:/Users/name/Music/*.{mp3, MP3}']
puts 'what would you like to call the playlist?'
@new = ''
playlist_name = gets.chomp + '.m3u'

music.each do |z|
  @new += z + '\n'
end

File.open playlist_name, 'w' do |f|
  f.write @new
end

推荐答案

使用"\n"代替'\n'

这篇关于如何在输出中进行换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆