# 获取文件对象f = open("abc.txt", "r", encoding="utf8")# 按行遍历内容# 办法1# for line in f.readlines():# print(line)# 办法2# for line in f:# print(line)# 关闭资源f.close()
# 获取文件对象f = open("abc.txt", "r", encoding="utf8")# 按行遍历内容# 办法1# for line in f.readlines():# print(line)# 办法2# for line in f:# print(line)# 关闭资源f.close()