将文本复制并粘贴到特定点和线上

发布于 2025-01-15 12:01:48 字数 245 浏览 1 评论 0原文

所以我有这个 .json 文件和很多我需要放入其中的文本 现在我不想选择所有内容并将其一一粘贴到目的地

所以例如我有“”,我想粘贴我的文本以使其成为

“paste1”
“粘贴2”
“paste3”

我如何能够通过将每一行作为单独的行,但在该行的同一目的地保持相同的格式,将我的内容从 txt 复制到 .jsons 中? 就像我怎样才能在“”之间粘贴东西,但每次粘贴都会在不同的行中结束?

希望有人能帮助我

so i have this .json file and a lot of text i need to put in there
Now i dont want to select everything and paste it one by one to its destination

So for example i have "" and i want paste my text to make it

"paste1"
"paste2"
"paste3"

How would i be able to copy my stuff from the txt, into the .jsons by making every line as seperate line, but keeping it in the same format at the same destination for that line?
Like how can i paste stuff between the "" but every paste would end up in a different line?

Hope someone could help me out

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〃温暖了心ぐ 2025-01-22 12:01:48

您必须将 txt 文件读入一个变量,该变量将在其中存储文件数据。
然后,您必须在每个新行分割数据,这将返回一个您可以根据自己的喜好进行操作的数据数组。

以下是您可能使用 JavaScript 编写的部分代码的示例:

//data is the variable we have stored our txt file info in
let arr = data.split("\n") // <-- splitting the data which returns an array which we store in a variable called "arr"
for(let i=0;i<arr.length;i++){
  arr[i] = "\""+arr[i]+"\"" //arr[i] is the value at every line and we are surrounding it with quotation marks
}

您当然可以以任何您想要的方式操作数据,然后以您想要的任何格式保存数据。

You have to read the txt file into a variable which will store the file data in it.
Then you would have to split the data at every new line which will return an array of data that you can manipulate to your liking.

Here's a sample of part of the code you might write using Javascript:

//data is the variable we have stored our txt file info in
let arr = data.split("\n") // <-- splitting the data which returns an array which we store in a variable called "arr"
for(let i=0;i<arr.length;i++){
  arr[i] = "\""+arr[i]+"\"" //arr[i] is the value at every line and we are surrounding it with quotation marks
}

You can of course manipulate the data in whatever way you want and after that you would save the data in any format you'd like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文