[已解决]爬虫成功,但是cmd中显示的格式很有问题
应该怎么样解决这个格式问题?
【已解决】利用string.trim() 或string.replae()来删除所获取字符串的空格
function printInfo(courses){ courses.forEach(function(currentCourse){ var chapterTitle = currentCourse.chapterTitle; // console.log(chapterTitle.trim()+"\n"); console.log(chapterTitle.replace(/\s+/g,"")+"\n"); var videos = currentCourse.videos; videos.forEach(function(video){ // console.log("【"+ video.id.trim() +"】"+video.title.trim() +"\n") console.log("【"+ video.id.replace(/\s+/g,"") +"】"+video.title.replace(/\s+/g,"") +"\n") }); }); }