What are the access modes for opening python files?

青灯夜游
Release: 2020-08-29 11:31:48
Original
28089 people have browsed it

The access modes for opening python files are: "r" mode, "w" mode, "a" mode, "rb" mode, "wb" mode, "ab" mode, "r" mode, " "w" mode, "a" mode, "rb" mode, "wb" mode, "ab" mode.

What are the access modes for opening python files?

Several access modes for opening python files

Access mode Instructions
r Open the file in read-only mode. The file pointer will be placed at the beginning of the file. This is the default mode.
w Open a file for writing only. If the file already exists, it is overwritten. If the file does not exist, create a new file.
a Open a file for appending. If the file already exists, the file pointer will be placed at the end of the file. In other words, new content will be written after existing content. If the file does not exist, create a new file for writing.
rb Open a file in binary format for reading only. The file pointer will be placed at the beginning of the file. This is the default mode.
wb Open a file in binary format for writing only. If the file already exists, it is overwritten. If the file does not exist, create a new file.
ab Open a file in binary format for appending. If the file already exists, the file pointer will be placed at the end of the file. In other words, new content will be written after existing content. If the file does not exist, create a new file for writing.
r Open a file for reading and writing. The file pointer will be placed at the beginning of the file.
w Open a file for reading and writing. If the file already exists, it is overwritten. If the file does not exist, create a new file.
a Open a file for reading and writing. If the file already exists, the file pointer will be placed at the end of the file. The file will be opened in append mode. If the file does not exist, a new file is created for reading and writing.
#rb Open a file in binary format for reading and writing. The file pointer will be placed at the beginning of the file.
wb Open a file in binary format for reading and writing. If the file already exists, it is overwritten. If the file does not exist, create a new file.
ab Open a file in binary format for appending. If the file already exists, the file pointer will be placed at the end of the file. If the file does not exist, a new file is created for reading and writing.

Recommended learning: Python video tutorial

The above is the detailed content of What are the access modes for opening python files?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template