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', '\r\n' 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. |
|
|
Undocumented
|
readinto()
Don't use this; it may go away. |
|
|
next line from the file, as a string
|
|
list of strings, each a line from the file
|
readlines(size=...)
Call readline() repeatedly and return a list of the lines so read. |
|
|
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
|
|
Inherited from object :
__format__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|