如何转到文件末尾? [英] How to go to the end of the file?
本文介绍了如何转到文件末尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打开了一个写数字的文件.我必须在文件末尾写上数字
I have opened a file to write a number. I have to write the number at the end of the file so
如何转到最后一行写?
推荐答案
您应使用以下文件打开文件
You should open the file with
open(..., position="append",...)
或者,您可以查询文件的大小
Alternatively, you can inquire for the size of the file
inquire(...,size=some_integer_variable,...)
然后,如果文件是直接访问文件,则可以使用此大小来计算最终记录的记录号.或者,如果访问模式为流",则可以使用
then if the file is a direct access file, you can use this size to calculate the record number of the final record. Alternatively, if the access mode is "stream", you can use
write(..., pos=some_integer_variable)
从文件末尾开始写.
这篇关于如何转到文件末尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文