clean_local_upload.py 481 B

1234567891011121314151617181920
  1. import os
  2. import json
  3. def set_num(img_num):
  4. record_dict = {"img_num": img_num}
  5. with open("static/record.json", "w") as f:
  6. json.dump(record_dict, f)
  7. print("加载入文件完成...")
  8. # 清空图片文件,并且将record设置为零
  9. if __name__ == '__main__':
  10. path = 'static/images'
  11. img_list = os.listdir(path)
  12. img_list.remove('index.txt')
  13. for name in img_list:
  14. os.remove(os.path.join(path, name))
  15. set_num(0)
  16. print('end')