Files

Files
AaronHandling text files
1 | f1 = open(“FileA.txt”, “r”) |
Handling random files
1 | import pickle |
File modes
... = open(“FileA.dat”, “rb”)
| Mode | Python |
|---|---|
| 只读 | "rb" |
| 清空+写入 | "wb" |
| 创建+写入 | "wb+" |
| 续写 | "ab" |


1 | f1 = open(“FileA.txt”, “r”) |
1 | import pickle |
... = open(“FileA.dat”, “rb”)
| Mode | Python |
|---|---|
| 只读 | "rb" |
| 清空+写入 | "wb" |
| 创建+写入 | "wb+" |
| 续写 | "ab" |