os.path.exists("exercise_1.py")
os.remove(‘1.txt‘)
import os if os.path.exists("demofile.txt"): os.remove("demofile.txt") else: print("The file does not exist")
python 检查文件是否存在和删除文件
原文:https://www.cnblogs.com/hkj8808/p/15013832.html