Comparison of read(), readline() and readlines() in Python

1. Every time read() reads the entire file, it usually reads the content of the file into a string variable, which means that the content of the file generated by .read() is a string type.
2. readline() reads one line of the file each time, usually the content of the read line is put into a string variable, and the str type is returned.
3. readlines() reads the entire file content line by line each time, puts the read content into a list, and returns the list type.

Guess you like

Origin blog.csdn.net/weixin_42760923/article/details/107426418