初学python 文件操作



常用文件操作
文件操作 描述
file.read() 将整个文件读入字符串中
file.readline() 读入文件的一行字符串中
file.readlines() 将整个文件按行读入列表中
file.write() 向文件中写入字符串
file.writelines() 向文件中写入一个列表
file.close() 关闭打开的文件


python 的内置函数

     open(filename,mode,bufsize)

      filename :要打开的文件名

      mode:可选参数,文件打开模式

      bufsize:可选参数,缓冲区大小


你可能感兴趣的:(python,文件处理)