python - 通过 open() "w" 模式创建文本文件
问题描述
在哪里记录了 open() 中的“w”模式创建了一个新文件?我浏览了所有信息https://docs.python.org/3/library/functions.html#open,但我没有找到任何关于为什么这个“w”会创建一个新文本文件的信息。
解决方案
我相信您使用的是 cpython,它在内部使用 C 标准库函数 fopen()。 http://www.manpagez.com/man/3/fopen/
``w'' Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
``w+'' Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at
the beginning of the file.
推荐阅读
- c# - 泛型发生在 GDI+
- php - json_encode 不接受列或特殊章程或空白
- excel - 用于替换表中的值的宏
- kubernetes - 在私有 vpc 和 NAT 中连接 GCP Kubernetes
- flutter - Flutter - 在 pubspec.yaml 中添加 pub 包
- python - 如何获取html页面中的所有标签和信息(特别是页面中的所有链接)?
- r - 如何使用 postgres 触发器执行 r 脚本
- java - 如何扩展 apache FTPFile 的功能?
- javascript - 无法让画布显示自定义字体
- node.js - 颤动的firestore node.js没有生成带有node.js的函数文件夹