import requests import os import time def send_file(file_path, url): with open(file_path, 'rb') as file: response = requests.post(url, files={'file': file}) if response.status_code == 200: print('File sent successfully.') else: print('Failed to send file.') # 示例用法 file_path = '销量达标.csv' url = 'http://125.94.215.54:5001/receive-file' send_file(file_path, url) time.sleep(2) try: # 判断文件是否存在 if os.path.exists(file_path): # 删除文件 os.remove(file_path) print("成功删除文件") else: print("文件不存在") except Exception as e: print("发生错误:", str(e)) time.sleep(5)