我如何使\n我的输出真正起作用?目前它只是把它全部写在 1 个长块中。谢谢你的帮助
\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
使用"\n"代替'\n'
"\n"
'\n'