You need to explicitly terminate the str with a '\n', if needed. fileObj.write( str) -> int: Write the given string to the file and return the number of characters written.fileObj.read() -> str: Read the entire file into a string.fileObj.readlines() -> : Read all lines into a list of strings.It returns an empty string after the end-of-file (EOF). fileObj.readline() -> str: (most commonly-used) Read next line (upto and include newline) and return a string (including newline). It initially positions at the beginning of the file and advances whenever read/write operations are performed. The fileObj returned after the file is opened maintains a file pointer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |