如何\n在输出中实际工作?目前它只是在一个长块中写入它.谢谢你的帮助
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
Run Code Online (Sandbox Code Playgroud)