python文件IO

文件IO
生成文件对象
fileobj=open(filename,mode) (2,3) file(只支持2版本)
fileobj.read()
fileobj.readline()
fileobj.readlines()
fileobj.close()
fileobj.next() //返回当前行,移动文件指针到下一行
fileobj.write()
fileobj.flush(); //不关掉时刷入到文件
fileobj.seek(偏移量,选项);
选项
0:指针移动到文件头
1:从当前位置,向后移动"偏移量"字节
2:将文件指针从文件尾部向前移动"偏移量"字节 2进制rb

输入写入到文件

f=open("f.txt",'a+')
while True:
    s=input("please input:")
    if s == 'q':
        f.seek(0,0)
        print("you input:------\n",f.read())
        f.close()
        break;
    else:
        f.write(s+"\n")