read()

Read(229) Label: file object, read as a string,

Here’s how to use read() function.

f.read()

Description:

Read contents of a file and return result as strings.

Syntax:

f.read()

Note:

The function retrieves the contents of file f and returns them as strings.

Parameters:

f    A file

Options:

@n

Return the contents of the file object f as a string sequence; each row is corresponding to a member.

@v

Return a sequence as the corresponding data type. The combined use of this option and @n is acceptable

Return value:

A string

Example:

 

 

 

A

 

 

 

1

=file("D:/score.txt")

 

 

 

2

=A1.read()

Read the contents of file object score.txt as a string

 

 

3

=A1.read@n()

With @n option, read and concatenate each line in the text file into a string and return it as a member of the resulting sequence

 

 

4

=file("D:/tmp2.txt")

 

 

 

5

=["Lucy","98"]

By default Lucy is a string and 98 is an integer

 

 

6

=A4.write(A5)

 

 

 

7

=A4.read@nv()

With @nv options, return a sequence consisting of rows of different data types

 

 

8

=A1.read@s()

Read the text file as the binary blob data

 

  Related functions:

f.write()