What's a reasonable way to read an entire text file as a single string?

后端 未结 2 1206
[愿得一人]
[愿得一人] 2021-02-02 05:15

I am sure this is an easy one; I just couldn\'t find the answer immediately from Google.

I know I could do this (right?):

text = \"\"
File.open(         


        
2条回答
  •  野的像风
    2021-02-02 06:11

    What about IO.read()?

    Edit: IO.read(), as an added bonus, closes the file for you.

提交回复
热议问题