Returns the contents of a file as a string. Starts reading from current position in file. Args: n: Read 'n' bytes if n != -1. If n = -1, reads to end of file. Returns: 'n' bytes of the file (or whole file) in bytes mode or 'n' bytes of the string if in string (regula
(self, n=-1)
| 108 | compat.as_bytes(file_content), self._writable_file) |
| 109 | |
| 110 | def read(self, n=-1): |
| 111 | """Returns the contents of a file as a string. |
| 112 | |
| 113 | Starts reading from current position in file. |
| 114 | |
| 115 | Args: |
| 116 | n: Read 'n' bytes if n != -1. If n = -1, reads to end of file. |
| 117 | |
| 118 | Returns: |
| 119 | 'n' bytes of the file (or whole file) in bytes mode or 'n' bytes of the |
| 120 | string if in string (regular) mode. |
| 121 | """ |
| 122 | self._preread_check() |
| 123 | if n == -1: |
| 124 | length = self.size() - self.tell() |
| 125 | else: |
| 126 | length = n |
| 127 | return self._prepare_value( |
| 128 | pywrap_tensorflow.ReadFromStream(self._read_buf, length)) |
| 129 | |
| 130 | @deprecation.deprecated_args( |
| 131 | None, "position is deprecated in favor of the offset argument.", |