gpt4 book ai didi

javascript - 使用 fs.read 时没有将值返回到 console.log

转载 作者:行者123 更新时间:2023-12-02 15:59:56 25 4
gpt4 key购买 nike

我需要帮助来读取文本文件 information.txt,并使用 console.log 显示值。

这是代码:

fs.readFileSync("information.txt", "utf-8", function (err, data) {                                                                                         
if (err) {
throw err;
}

var content = data;
console.log(content);
});

最佳答案

您的代码中有一些错误,这是一个工作版本:

var fs = require('fs');

var content = fs.readFileSync("themes", "utf-8");
console.log(content);

关于javascript - 使用 fs.read 时没有将值返回到 console.log,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31277744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com