Open a file. The mode can be 'r', 'w' or 'a' for reading (default),
writing or appending. The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing. Add a 'b' to the mode for binary files.
Add a '+' to the mode to allow simultaneous reading and writing.
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size. The preferred way
to open a file is with the builtin open() function.
Add a 'U' to mode to open the file for input with universal newline
support. Any line ending in the input file will be seen as a 'n'
in Python. Also, a file so opened gains the attribute 'newlines';
the value for this attribute is one of None (no newline read yet),
'r', 'n', 'rn' or a tuple containing all the newline types seen.
'U' cannot be combined with 'w' or '+' mode.
|
|
self.
|
|
None
|
__exit__(*excinfo)
Closes the file. |
|
|
|
|
file object
|
__init__(name,
mode=...,
buffering=...)
x.__init__(...) initializes x; see help(type(x)) for signature |
|
|
|
|
a new object with type S, a subtype of T
|
|
|
|
|
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value |
|
|
None or (perhaps) an integer
|
|
integer "file descriptor"
|
fileno()
This is needed for lower-level file interfaces, such os.read(). |
|
|
None
|
flush()
Flush the internal I/O buffer. |
|
|
true or false
|
isatty()
True if the file is connected to a tty device. |
|
|
the next value, or raise StopIteration
|
|
read at most size bytes, returned as a string
|
read(size=...)
If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was requested
may be returned, even if no size parameter was given. |
|
|
Undocumented
|
readinto()
Don't use this; it may go away. |
|
|
next line from the file, as a string
|
readline(size=...)
Retain newline. A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF. |
|
|
list of strings, each a line from the file
|
readlines(size=...)
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned. |
|
|
None
|
seek(offset,
whence=...)
Move to new file position. |
|
|
current file position, an integer (may be a long integer).
|
|
None
|
truncate(size=...)
Truncate the file to at most size bytes. |
|
|
None
|
write(str)
Write string str to file. |
|
|
None
|
writelines(sequence_of_strings)
Write the strings to the file. |
|
|
returns self
|
xreadlines()
For backward compatibility. File objects now include the performance
optimizations previously implemented in the xreadlines module. |
|
|
Inherited from object :
__format__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|