diff --git a/content/posts/2024-05-21.md b/content/posts/2024-05-21.md new file mode 100644 index 0000000..bfcd7fe --- /dev/null +++ b/content/posts/2024-05-21.md @@ -0,0 +1,14 @@ ++++ +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) 重新将 +文件位置置于开头。