Python is read and readlines difference
1. First look read
dir=r"G:\数据集\celebA\celebA(分卷形式,一起解压)\celebA\Anno\list_bbox_celeba.txt"
file=open(dir)
print(file.read())
print(type(file.read()))
Output for the
output of all content, format type is str
2. Look readlines
dir=r"G:\数据集\celebA\celebA(分卷形式,一起解压)\celebA\Anno\list_bbox_celeba.txt"
file=open(dir)
# print(file.read())
# print(type(file.read()))
print(file.readlines())
print(type(file.readlines()))
Output
is a List , which put the contents one by one