filename='student.txt'
with open(filename, 'r', encoding='utf-8') as stu_txt:
print(stu_txt.readlines())
print(type(stu_txt.readlines())) # list
stu_lst = stu_txt.readlines() #
print(stu_lst)
输出结果:
["{'id': 1001, '姓名': '张三', '语文': 90, '数学': 90, '英语': 90}\n", "{'id': 1002, '姓名': '李四', '语文': 85, '数学': 95, '英语': 75}\n"]
<class 'list'>
[]
为什么
print(stu_lst)
输出结果为空列表?