python3 post图片

本文详细介绍了如何使用Python3进行图片上传操作,包括必要的库的导入、文件读取、HTTP请求的构造等步骤,帮助读者掌握在Web应用中通过Python上传图片的方法。

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import base64
import os
import mimetypes
import requests
import time

import cv2

import requests
import json

postUrl = "https://api-arcloud.sensetime.com/arcloud/face/handle"
userPic = r"D:\tz1.jpg"
assistant_image_url = "http://photocdn.sohu.com/20081209/Img261098853.jpg"
assistant_image_data = r"D:\b1.jpg"

def get_time_stamp():
    ct = time.time()
    return int(round(ct * 1000))

def get_content_type(filepath):
    return mimetypes.guess_type(filepath)[0] or 'application/octet-stream'

fields = {
    "app_id": "165xxxxxxxxx",
    "timestamp": '%s' % get_time_stamp(),
    "protocol_version": "1.0.0",
    "ar_types": "facefusion",
    "facefusion_params": '{"template_weight": 0}',
}
files = {
}
with o
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值