python-3.x - 如何解析包含 csv 文件的 Http 请求
问题描述
我正在尝试处理 body 中包含 csv 文件的请求。python3中存在任何提取或解析http请求并获取csv文件的库。我是python的初学者。
我的请求
file = {'file': open('../file/10.csv', 'rb')}
response = requests.post('http://127.0.0.1:8080/function/preprocess', files=file)
print(response.content)
我的处理程序
def handle(event, context):
return {
"statusCode": 200,
"body": event.body
}
邮差
---------------------------157082355573515401018537
Content-Disposition: form-data; name="file"; filename="10.csv"
Content-Type: text/csv
id,vendor_id,pickup_datetime,dropoff_datetime,passenger_count,pickup_longitude,pickup_latitude,dropoff_longitude,dropoff_latitude,store_and_fwd_flag,trip_duration
id2875421,2,2016-03-14 17:24:55,2016-03-14 17:32:30,1,-73.982154846191406,40.767936706542969,-73.964630126953125,40.765602111816406,N,455
----------------------------157082355573515401018537--
解决方案
推荐阅读
- javascript - 生产构建中的应用程序中断
- python-3.x - 在python中增加字符串的最后一位
- c++ - 用>=比较字符串是什么意思
- docker - 无法在 minikube 的 docker daemon 中创建 docker 镜像
- scala - Scala StructType 在 Databricks 中流式传输的问题
- python - Python Marshmallow 基于条件的验证
- python - 查找数字列表的阶乘 Python
- java - 导入 Jar 的 Spring bean 属性被应用程序 bean 定义覆盖
- reactjs - React Intl,如何一次编译多个语言文件?
- java - 如何验证 @PathVariable 已设置?