You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
528 B

2 months ago
import requests
# 目标 URL
url = 'http://127.0.0.1:8000/polls/upload/' # 确保与 Django 开发服务器地址一致
# 准备要上传的 Excel 文件
files = {
'file': open('D:/python20240709/pycharm/mingdan.xlsx', 'rb') # 替换为你的 Excel 文件路径
}
# 发送 POST 请求
response = requests.post(url, files=files)
# 检查响应状态和内容
if response.status_code == 200:
print("学生信息上传成功:", response.json())
else:
print("上传失败:", response.status_code, response.json())