大佬教程收集整理的这篇文章主要介绍了node.js – NodeJS,fs.readFileSync逐字符串读取和操作.怎么样?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我如何在NodeJS中通过字符串读取文件字符串的某些值,例如 – url,并最终对每个字符串进行操作?
var contents = fs.readFileSync('test.txt','utf8');
什么呢?
这需要browserstack SELEnium测试.
我想从文件中逐个运行一些链接并对它们做一些事情.
更改了以下代码:
从
console.log(lines[i++])
至
line = (lines[i++]) driver.get(linE); driver.getCurrentUrl() .then(function(currentUrl) { console.log(currentUrl);
但它工作一次.
和
var str=fs.readFileSync('test.txt'); str.split(/\n/).forEach(function(linE){}) C:\nodejstest>node test1.js C:\nodejstest\test1.js:57 str.split(/\n/).forEach(function(linE){ ^ TypeError: str.split is not a function at Object.<anonymous> (C:\nodejstest\test1.js:57:5) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10) at startup (node.js:142:18) at node.js:939:3
作品!
太多了!
var buf=fs.readFileSync(filepath); buf.toString().split(/\n/).forEach(function(linE){ // do something here with each line });
以上是大佬教程为你收集整理的node.js – NodeJS,fs.readFileSync逐字符串读取和操作.怎么样?全部内容,希望文章能够帮你解决node.js – NodeJS,fs.readFileSync逐字符串读取和操作.怎么样?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。