Python 文件 I/O
文件读写
with open('Game/Dota.txt','w')as file:
file.write('Radiant Victory! ')
当Game文件夹未创建时,出现FileNotFoundError
必须手动创建文件夹,或者用
import os # 创建的目录 path = "Game/Valve/" if not os.path.exists(path): os.makedirs(path)
| 模式 | r | r+ | w | w+ | a | a+ |
| 读 | * | * | * | * | ||
| 写 | * | * | * | * | * | |
| 创建 | * | * | * | * | ||
| 覆盖 | * | * | ||||
| 指针在开始 | * | * | * | * | ||
| 指针在结尾 | * | * |

浙公网安备 33010602011771号