gpt4 book ai didi

javascript - 从数组到新行的 writeFile 不起作用

转载 作者:行者123 更新时间:2023-11-30 11:17:45 26 4
gpt4 key购买 nike

const file = [1,2,3]
fs.writeFile(path, file.join(',') + '\n')

而且我看到保存的文件内容还是1,2,3

我怎样才能像这样将每个数组保存在一个新行中?

1
2
3

最佳答案

你用逗号连接你的数组,然后在末尾添加一个新行。你想改变你的加入:fs.writeFile(path, file.join('\n'))

关于javascript - 从数组到新行的 writeFile 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50939909/

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