且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检索和替换文本文件中的数字

更新时间:2023-02-23 17:30:22

如果您需要更改第一行的长度,那么您将不得不读取整个文件并再次写入.我建议先写入一个新文件,然后在确定文件写入正确后重命名该文件,以避免在操作中途程序崩溃时丢失数据.

If you need to change the length of the first line then you are going to have to read the entire file and write it again. I'd recommend writing to a new file first and then renaming the file once you are sure it is written correctly to avoid data loss if the program crashes halfway through the operation.