import os
# os.path.exists(path) 判断文件或目录是否存在
if not os.path.exists('demo.txt'):
os.makedirs('demo.txt')
# 文件 IO
# 读取文件的时候,文件必须存在 open('demo.txt', 'r')
# 写入文件的时候,如果文件不存在,会自动创建文件 open('demo.txt', 'w')
文件IO
发布时间 2023-07-08 09:25:19作者: hacker_dvd