如何\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