#!/usr/bin/env python# *_* coding=utf-8 *_* "" "Desc: File Method ############################ #file. Read () #read ([size])-&G T Read at most size bytes, returned as a string. File.readline () ReadLine ([size]), next line from the file, as a string. File.readlines () readlines ([size]), List of strings, each a line from the file. Call ReadLine () repeatedly and return a list of the lines so read. The optional size argument, if given, is a approximate bound on the all number of bytes in the lines returned.fi Le.xreadlines () Xreadlines (), returns self. File.write () write (str), None. Write string str to File.file.writelines () Writelines (sequence_of_strings), None. Write the strings to the file. Note that newlines is not added. The sequence can is any iterable object producing strings. This is equivalent to calling write () for each string.file.truncate () Truncate ([size]), None. Truncate the file to in the most size bytes. Size defaults to the current file position, as returned by Tell (). File.seek () Seek (offset [, whence]) method changes the position of the current file. The offset variable represents the number of bytes to move. The from variable specifies the reference position at which to begin moving bytes. If from is set to 0, this means that the beginning of the file is used as the reference location for moving bytes. If set to 1, the current position is used as the reference location. If it is set to 2, then the end of the file will be used as the reference location. File.flush () File.tell () current file position, an integer (could be a long integer). File.next () File.close () ########### #不常用的方法 ############ #file. closed File.mode file. Name File.isatty () # True or False. True if the file is connected to a TTY device. File.readinto () #不用用这个 file.encoding # infrequently used File.errors # not commonly used File.newline # File.softspace File.fileno () Fileno () , integer "File descriptor". This is needed for Lower-level file interfaces, such Os.read (). ############################## #version: 1.0 "" "Fo= Open (" E:/temp.txt ", ' R ') print" file name: ", Fo.nameprint" is closed: ", Fo.closedprint "access mode:", Fo.modeprint "at the end of whether to force a space:", fo.softspace
-file method of Python application