您所在的位置:小祥子 » 编程 » Python » 正文

Python学习(九)IO 编程 —— 文件读写

时间:2015-05-08 编辑:feesland 来源:本站整理

Python 文件读写

  Python内置了读写文件的函数,用法和C是兼容的。本节介绍内容大致有:文件的打开/关闭、文件对象、文件的读写等。

  open()   close()     with open(...) as ...

    看以下示例就能了解 Python 的 open() 及 close() 函数。这边调用 read()方法可以一次读取文件的全部内容,Python把内容读到内存,用一个str对象表示,具体使用参见下文。

    在 E 盘 python_file 文件夹下新建一 a.txt,输入随意,如下:

      JS6GKo2zZxAAAMpPQPw2y5lz53/W9HO7vb3040ZpWVhqupYM9Zlnt3/ve3+nTaY+8+z25194UW2G6t9QpV1/pghDtU/W5mWo9gzVxVBLl6HaDTWTyUR1tOSyAEPVtisx1GqbFAcAkBLoPJowpkv9GKpThmocrv2r2admqOJcrPI5VLHkq/X7TiVfcbvhDe+9955YioxGo0at0t1QLaXmXbt22euTnobqXsy0zKEaru9OvnOoxiSoce3ay23evHnz5s325kmv0SXaRRqqNM5+rg4AoMzkV/IVZTfUyL43DBmGKi4Vlp6q+FW+RlVww4YNe/bs8VyUlEwmtcs0NkajUW23F1980WeGKp4nEAi4mI1xfnumZVnla4Row4YNyWRSNNRSrPLVXvSnP/2pPUQZYTZa+9O4BG1Rkv0aXRYlFWOo0jgDAFQh2R5cyzs9M1SLIvveEJ3SmDT9w4GDgUBA+tNIPjNUF62nnx70uXa3RN9Dda8zV9WvSQAAVD/8lm+FMeYpXSiRt7n/4oTPCnO+zJm/40TSCQDrBgy1fnEyVO2LofgcAEBeYKgAAAAKwFABAAAUgKECAAAoIDBxd6nmVOmgAQAAWAlcAgAAgKIJVNrRAQAA1gMYKgAAgAIwVAAAAAVgqAAAAArAUAEAABSAoQIAACgAQwUAAFAAhgoAAKCAwOLiEkIIIYSKVGAhlUYIIYRQkQr09PwZIYQQQkWKOVSAPLg2m650E+oC4lwe6i3Opb5eDLVmeCr0r5VuAtRdB1QpiHN5qLc4Y6iQyWQy33/pX374+xMv7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AARgqAACAAjBUAAAABWCoAAAACsBQAQAAFIChAgAAKABDBQAAUACGCgAAoAAMFQAAQAEYKgAAgAIwVAAAAAVgqAAAAArAUAEAABSAoQIAACgAQwUAAFAAhgoAAKCA/wcAC0iUu6M8MQAAAABJRU5ErkJggg==" alt="" onload="return imgzoom(this,600);" />

    Python 操作 打开及关闭方式 如下:

      ASPAVJ71DfRtEM47KqDvXoZjkvfbrV7QXbdnN//E73eoJFc/0ekXS+Q9/djTdFmRWTU5bF7dbuwPQ8Z+ZVpQLvAqxApEKjEA/yvKrFv7DzjBZpC/+wG9M4g8wpwLsAK5DSuw8i3dtbs+T4tuG5GY9NU/uF3djGn+1jykbBuwArkNK74kHyLsCLgHcBViCld5Hu3TF8uajjqcI2LAXeBViBlN4V5F2ALYF3AVYgpXeRLsCmwLsAK5DSu4K8C7Al8C7ACqT0LtIF2BR4F2AFUnpXkHcBtgTeBViBlN5FugCbAu8CrICPL4875Tl/0QsBiiR5t8iE/xMvzpXIirD2l1ujJ4LuqY7j01Ofy8FzJ8APvAuwAn7eHR7J/B69GtEm825TBHr3nus0+GFYhmj0HEqeswhe4F2AFQh1p+zgUIR/3j2LPBNZJopGVLnIMpFlovdKkYksE1khmuL6Uveg4HN1/VVW6XVjMbzaP1X42k5m2MuIvkDBlIC7Z1jk1fn2NItbIpWfbiE3Ih3AttRu0Yy9a7DsMz4RGpYH7wKsQJg53+doNzjvFpnIc8WpvYx64zajseJxhG0KkeWiqG7t5OJsrzxBaN7tVNrt0hSdeOV1F85VPqi3aeSFhqTF5/v6pnFm8zqDrKMH0+BdgBVIqN3g+7vandoqH37tvGvUis27N3MpOybwrr62keFRjqYcLC0PqGdftQOWaMtQM0yDdwFWIEic87Qbk3flxKZ71+JLs3f7Lat713SD9ro9U3Iw3oV7g3cBViBAmzPTblTeHRzZjMaZl/CuPEYte92K1buXKi+z/KSvSGvwripYY8vnKs/kcWZpqnLBODMsBt4FWIGE2o3Mu/3sp0EtzTAZSnOQPFXKMNnqNl1LvsU77CJtNKIPECtaG3tXn4alZnfDK9Iwc14UeSYNNUt1i9EtXuZVQSR4F2AFZok0EBGed0lsPvA9IogD7wKsQErvBki3D6aZdf4USPDcDIgB7wKsQErvCp7PDLAl8C7ACqT0LtIF2BR4F2AFUnpXkHcBtgTeBViBlN5FugCbAu8CrEBK7wryLsCWwLsAK5DSu0gXYFPgXYAVSOldQd4F2BJ4F2AFUnoX6QJsCrwLsAKeynw7lFdmPCtSROVd5SGJUQ+D6J+/aHgq8sLw/Ap4JPAuwAr4+PL9uOt1+3aIN29M3g1d/8fOWV729j7wvEZ4LPAuwAp4erd37ftxtzu+x3lXBOZdfWEBDwEPu+SV5lmjd6X1CZQsLa1QkGvLBNk7w/oE8GDgXYAV8DPmMMxc7o5x0v1w/7zbFNoS8hPerXKpRlP0KpVryuvuyQ2cq5z1+ODRwbsAK+CpXSnvHmLjbtT93QDv2taTl1tSPaz6UFoq13RP+awvA6hFZNafh4cD7wKsgJ92paFl5Zcw7px3F/SusvWWayfbx7vwYOBdgBXw8aWy4v0M74ol8+54nflOkWfpNyWQmsaZ5Q2DVpXtTdG3orY/gnFmeDTwLsAK+BlTur8744tEodLVB3YVfRm8q+0i6TIzN6QOHffNq8e1zLcavcS8Kng48C7ACsQ6NAbx7M+r4ntE8FjgXYAVSOnd55auEILnZsBjgXcBViCld8Wz512AxwLvAqxASu8iXYBNgXcBViCldwV5F2BL4F2AFUjpXaQLsCnwLsAKpPSuIO8CbAm8C7ACKb2LdAE2Bd4FSM//Ay7Ez/sAiyU/AAAAAElFTkSuQmCC" alt="" onload="return imgzoom(this,600);" />

    注意 open() 之后 一定要 close()。但由于文件读写时都可能产生IOError,为了保证无论是否出错都能正确地关闭文件,我们用 try ... finally 来实现:

      CSStMFR82PdLnbCqGahgr50nEfaQ4yRbKSO3kywM8NeAkDxX1aKauKs2QpdnK3cz5TNzQCXq3f7YT3eJz4hVhK0Owkrgqd3IOR9Bn/nwDAXJlTz/30cidjO6V1zzg0bW9S9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VN+n3cZwPFpVyBltyPy73EyW5jkr9o1Kv1Qe5A04ByX0ymedskYLHtWi5Cx6v1uZxnnO7PI2FviiAsC13VLLiQe6Ag0ByN12hadpTXB6dzKlyJ+Ys0/yrQN3ucqlnF4HYnfJmKCo36B5YFNblPn71NlkZHJf7iuJ7iTLIHXAQSO6Tib3k7udVRQsel64NY5S7x0Xs4eexr8k9/bzqcfIAgsel97vfx3Fe/elDCLjIRg2wMGzJXaj0k5V+stI/rvSR5dv9lyB3wCGsJ3cd5ya5Tya25O7nTffUy13wuLTS9fMapStoThdaNM9nhHTozDiETbkPhMogiarcT4LcASexmNypX88Py5G7ZquS0KceH+S+TGzJPVUdCNUBUjxK8e0ByB1wCovJfYl+X2pypyzi4efJRgzZpMFH0rVlyA2quzXb/Tw+ivb4BqAts1Tsyh2XUB0I1QHIHXAOSO4zrNBEPoVwMkc/kLbTgg+vfV3GhVbDQ3BBdbnYkPvrtye1AVmp6kAEuQOOAcn9zAFDIZeILbmn64OT2iBdH6brQ+R3cQhyB5wCkvsZBG5iWhrW5f7y9dtMfUhWuj7sDF+B3AGHgOQOANY5jdwzIHfASSC5A4B1bMk92xhm6gOyOtCWARwDkjsAWMeW3HONYbY+zNYH2fogWx9m68MuJHfAMSC5A4B1bMk93xzmGnJlG8NsA+QOOAgkdwCwji25F1pSoSXlm8O8ovgutGUAx4DkDgDWsS73V6/fFprDQlMqNKV8c4iqK0FyB5wCkjsAWMeW3IstCVehOSw0hz2QO+AYkNwBwDq25F5qSSXV78NCC+QOOAgkdwCwjg25v3lbbkslXC2p1JJA7oBzQHIHAOvYknulPSq3JaVG5faoPwK5A04ByR0ArGNP7uKoIkoVUaogv4sgd8BBILkDgHWsy/31m3/WOuMqWeJ4MHoNcgccApI7AFjHjtzf1jqjKi5xVBVHIHfAMf4/ysGiowDNWWQAAAAASUVORK5CYII=" alt="" onload="return imgzoom(this,600);" />

    python 简化了改写法,即用 with open(...) as ...  ; 建议之后文件读写都用该写法:

    

    上面,你肯定注意到了参数 "r";该参数决定了打开文件的模式:只读,写入,追加等。所有可取值见如下的完全列表。这个参数是非强制的,默认文件访问模式为只读(r)。

模式描述
r 以只读方式打开文件。文件的指针将会放在文件的开头。这是默认模式。
rb 以二进制格式打开一个文件用于只读。文件指针将会放在文件的开头。这是默认模式。
r+ 打开一个文件用于读写。文件指针将会放在文件的开头。
rb+ 以二进制格式打开一个文件用于读写。文件指针将会放在文件的开头。
w 打开一个文件只用于写入。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件。
wb 以二进制格式打开一个文件只用于写入。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件。
w+ 打开一个文件用于读写。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件。
wb+ 以二进制格式打开一个文件用于读写。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件。
a 打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。也就是说,新的内容将会被写入到已有内容之后。如果该文件不存在,创建新文件进行写入。
ab 以二进制格式打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。也就是说,新的内容将会被写入到已有内容之后。如果该文件不存在,创建新文件进行写入。
a+ 打开一个文件用于读写。如果该文件已存在,文件指针将会放在文件的结尾。文件打开时会是追加模式。如果该文件不存在,创建新文件用于读写。
ab+ 以二进制格式打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。如果该文件不存在,创建新文件用于读写。

  File 对象

    file 为一对象,它有一些内置属性,如下

      

文件对象属性描 述
file.closed 表示文件已经被关闭,否则为False
file.mode Access文件打开时使用的访问模式
file.encoding 文件所使用的编码
file.name 文件名
file.newlines 未读取到行分隔符时为None,只有一种行分隔符时为一个字符串,当文件有多种类型的行结束符时,则为一个包含所有当前所遇到的行结束的列表
file.softspace 为0表示在输出一数据后,要加上一个空格符,1表示不加。这个属性一般程序员用不着,由程序内部使用

  

  read()    read(size)   readline()   readlines()

    之前的例子已经接触到了 read() 函数,该函数会会一次性读取文件的全部内容,如果能确保文件的大小,自然可以。但若文件过大,内存就爆了,所以,可以反复调用read(size)方法,每次最多读取size个字节的内容;也可调用 readline() 每次读取一行内容;而调用readlines()可以一次读取所有内容并按行返回list。总之,根据需求来。仅以 txt 文件为例,其他的文件读取需要特殊处理;另外,文件的格式编码方式也需要注意;这边仅介绍读取方法,其他的会出专题来学习。

    在D:\python_file 下新建 poet.txt;示例如下,由于一个中文会占多个字节,故read(size) 部分会乱码,如:

    

    

    

  write()

    写文件和读文件是一样的,唯一区别是调用open()函数时,传入标识符'w'或者'wb'表示写文本文件或写二进制文件;'a' 对应的表示追加等。

    如下示例,由于 write.txt 文件不存在,创建该文件并写入:

    

    在上例基础上,继续,该文件被重写:

    

    继续,这次使用追加,会在文件结尾追加:

    

    

关键词:编程 学习 文件 读写