15 lines
466 B
Markdown
15 lines
466 B
Markdown
|
+++
|
||
|
title = 2024-05-21
|
||
|
author = ["SouthFox"]
|
||
|
date = 2024-05-21T23:25:00+08:00
|
||
|
lastmod = 2024-05-21T23:28:08+08:00
|
||
|
tags = ["publish"]
|
||
|
draft = false
|
||
|
+++
|
||
|
|
||
|
## Python 既读又写 {#python-既读又写}
|
||
|
|
||
|
[python]({{< relref "../main/20240521232625-python.md" >}}) 中 open 函数为 `r+` 模式时为即读又能写,但是读完整个文件后
|
||
|
文件位置将处于最末尾,这时写入相当于追加写,需要使用 seek(0) 重新将
|
||
|
文件位置置于开头。
|