python第九期学习笔记(三)
作者:互联网
#!/usr/bin/python3
#_*_ coding:utf-8 _*_
#author:inwell
#Time:2019/10/15 16:14
# f=open("1_homework.py",mode="r",encoding="utf-8")
# #读取前10个字符
# msg=f.read(10)
# #读取10个字符以后的字符
# msg1=f.read()
# print(msg)
# print(msg1)
# f.close()
# f=open("02 format.py",mode="r",encoding="utf-8")
# readline()一次只读取一行内容
# msg1=f.readline()
# msg2=f.readline()
# msg3=f.readline()
# msg4=f.readline()
# print(msg1)
# print(msg2)
# print(msg3)
# print(msg4)
# f.close()
f=open("02 format.py",mode="r",encoding="utf-8")
#readlines()返回一个列表,列表里面每个元素是原文件的每一行,如果文件很大,占内存,容易崩盘
msg=f.readlines()
print(msg)
标签:10,msg1,python,笔记,msg,第九期,print,utf,readline 来源: https://www.cnblogs.com/gaoyuxia/p/11684099.html