语法:fileObject.seek(offset,whence) offset -- 开始的偏移量,也就是代表需要移动偏移的字节数 whence:可选,默认值为 0.给offset参数一个定义,表示要从哪个位置开始偏移:0代表从文件开头开始算起,1代表从当前位置开始算起,2代表从文件末尾算起. '1,2'模式需要'b'二进制模式打开文件,否则报错. foo.txt This is 1st line This is 2nd line This is 3rd line This is 4th li…
一 文件操作 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 1.1打开文件读取内容 print(open("sounds","r",encoding="utf-8").read()) Somehow, it seems the love I knew was always the most destructive kind Yesterday when I was young The taste of life was…