标签:div 操作 style color print span 截取 python 模式
#读模式 f = open("abc.txt","r",encoding="utf-8") dat = f.read() print(dat) f.close() #写模式(覆盖) f_write = open("abc.txt","w",encoding="utf-8") f_write.write("111 222 333 5555") f.close() #追加模式 f_add = open("abc.txt","a",encoding="utf-8") f_add.write("\n888\n") f.close()
#句柄 with open("abc.txt","r",encoding="utf-8") as f_read1, open("abc.txt","a",encoding="utf-8") as f_add1: print(f_read1.read()) print(f_add1.write("989800000\n"))
#从哪个字节开始读
f_read1.seek()
#截取,截取多少个字节,其实就是写
f_write.truncate()
#read很特殊,5不一定代表5个字节
f_read1.read(5)
#光标所在的位置
f_read1.tell()
标签:div 操作 style color print span 截取 python 模式
原文地址:https://www.cnblogs.com/iamjames/p/10790338.html