简体   繁体   English

将多行文本转换为数组

[英]Convert multiple lines of text to Array

So I have a really long text document (10 million lines) and I want to convert that document to an array.所以我有一个非常长的文本文档(1000 万行),我想将该文档转换为数组。 For example, my text document is:例如,我的文本文档是:

a
b
c

and I want to convert this to:我想将其转换为:

["a","b","c"]

How can I do that?我怎样才能做到这一点?

First read document as plain text and use split method with split character '\n' .首先将文档作为纯文本读取,并使用带有拆分字符'\n' split方法。 This will split your document on new lines.这会将您的文档拆分为新行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM