在python中使用后删除文件对象

时间:2018-07-10 15:35:36

标签: python file flask

假设我读取了从输入表单上传的文件(CSV),然后对其进行处理:

file = request.files['file']
filename = secure_filename(file.filename)

#using the file object to predict result
df=pd.read_csv(file)
results = model.predict(df.v2)

#saving the file requested from the form to a dir
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return results

执行此操作后,文件“ test.csv”将立即从目录中上传。删除(删除)file对象的最干净方法是什么?

0 个答案:

没有答案