gpt4 book ai didi

javascript - 在 JavaScript 中将 Uint8Array 转换为字符串

转载 作者:行者123 更新时间:2023-12-02 22:08:24 41 4
gpt4 key购买 nike

我正在运行 where *.exe 以列出 Electron 应用程序中 Windows 中的所有 exe。然后启动一些应用程序。它以 Uint8Array 格式返回结果。

const { execSync } = require('child_process');
const exeFiles=execSync('where *.exe');
console.log( exeFiles); // this returns [97, 92,79,....]
console.log(exeFiles.toString());
// returns
//C:\Windows\System32\cacls.exe //C:\Windows\System32\calc.exe...

我希望结果是

[C:\Windows\System32\cacls.exe,C:\Windows\System32\calc.exe,...]        

最佳答案

如果希望结果为数组,可以根据换行符分割字符串并删除最后一个元素

const resultArray = exeFiles.toString().split("\n")
resultArray.pop() // since last element will be empty string
console.log(resultArray);

关于javascript - 在 JavaScript 中将 Uint8Array 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59640283/

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