输入文件是否需要程序直接处理?
在最新的美丽字符串问题中说,
5
ABbCcc
祝今年 Facebook 黑客杯好运!
请忽略标点符号:)
有时测试用例很难弥补。
所以我就去咨询 Dalves 教授
我将如何处理它在 javascript 中说的?
非常感谢
输入文件是否需要程序直接处理?
在最新的美丽字符串问题中说,
5
ABbCcc
祝今年 Facebook 黑客杯好运!
请忽略标点符号:)
有时测试用例很难弥补。
所以我就去咨询 Dalves 教授
我将如何处理它在 javascript 中说的?
非常感谢
为此,您可以使用node.js 文件系统 api(也可以在 node.js 中编写代码 - 它在 google v8 上,因此对于这个来说应该足够快)
编辑
我考虑了您的问题,并且可以更简单地解决(不使用 node.js)向文件发出 AJAX 请求。您可以这样实现:
var xmlhttp;
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// This logs the input.txt contents in the console.
// You can do whatever you want with it
console.log(xmlhttp.responseText);
}
}
xmlhttp.open("GET","input.txt",true);
xmlhttp.send();
}
如果您是初学者,您可以在W3Schools上阅读有关 AJAX 请求的更多内容
您可以选择更适合您的方法!祝你好运!