Skip to content

Commit ad17837

Browse files
Update Python Cheat Sheet
1 parent 5bf7714 commit ad17837

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

PythonCheatSheet.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,27 @@ print(text)
194194

195195
```
196196

197+
## Working with Files
198+
199+
```
200+
file_obj = open(file_name, "<mode>")
201+
```
202+
203+
| Mode | Description |
204+
| ------------- |:-------------:|
205+
| "r" | Read only. Default mode. |
206+
| "rb" | Read only in binary format |
207+
| "r+" | Read and write |
208+
| "rb+" | Read and write in binary format |
209+
| "w" | Write only. Overwrites existing file or creates a new file. |
210+
| "wb" | Write only in binary format. Overwrites existing file or creates a new file. |
211+
| "w+" | Read and write. Overwrites existing file or creates a new file. |
212+
| "wb+" | Read and write in binary format. Overwrites existing file or creates a new file. |
213+
| "a" | Append to existing file or creates new file. |
214+
| "ab" | Append to existing file or creates new file in binary format. |
215+
| "a+" | Read and append. Overwrites existing file or creates a new file. |
216+
| "ab+" | Read and append in binary format. Overwrites existing file or creates a new file. |
217+
218+
197219

198220

0 commit comments

Comments
 (0)