python, read (), readline (), readlines () difference

1, read ([size]) Method
Read ([size]) method reads the file size bytes from the current position, if no size parameter, indicates to the file read end position, as a String object that range
 
2, readline () method
As can be seen from the literal meaning, the process reads each line of text so that representing the memory read is relatively small, more suitable for large files, the method returns a String object
 
 
3, readlines () method to read the entire file all lines, saved in a list variable per line as an element, but read large files would be more total memory

Guess you like

Origin www.cnblogs.com/goulingyun/p/11025676.html