What are the different modes a file can be opened with?

Question

What are the different modes a file can be opened with?

Answer

Python’s open() function is capable of opening a file with several different mode options, which come in handy for different use cases! Below is a list of all the modes available, as seen on the documentation page:

4 Likes

What does “truncating” mean? What’s the purpose and how is it used?

3 Likes