用户/应用程序可以通过文件将数据永久保存的硬盘中
如何用文件
open()函数源码
========= ===============================================================Character Meaning--------- ---------------------------------------------------------------'r' open for reading (default)'w' open for writing, truncating the file first'x' create a new file and open it for writing'a' open for writing, appending to the end of the file if it exists'b' binary mode't' text mode (default)'+' open a disk file for updating (reading and writing)'U' universal newline mode (deprecated)========= ===============================================================The default mode is 'rt' (open for reading text). For binary randomaccess, the mode 'w+b' opens and truncates the file to 0 bytes, while'r+b' opens the file without truncation. The 'x' mode implies 'w' andraises an `FileExistsError` if the file already exists.
解析
控制文件读写内容的模式:t和b强调:t和b不能单独使用,必须跟r/w/a连用t文本(默认的模式)1、读写都以str(unicode)为单位的2、文本文件3、必须指定encoding='utf-8'b二进制/bytes控制文件读写操作的模式r只读模式w只写模式a只追加写模式+:r+、w+、a+
