Py学习  »  Python

如何使用remove.bg在Python中删除照片的背景

shy zhan • 6 年前 • 2312 次点击  

我想用 https://www.remove.bg 删除我照片的背景。 这是我的代码:

import requests            
response = requests.post(
    'https://api.remove.bg/v1.0/removebg',
    files={'image_file': open('U:/Training/python/remove-bg-master/child.jpg', 'rb')},   
    data={'size': 'auto'},
    headers={'X-Api-Key': 'API key'}   
)
if response.status_code == requests.codes.ok:
    with open('child-no-bg.png', 'U:\Training\python\remove-bg-master') as out:           
        out.write(response.content)
else:
    print("Error:", response.status_code, response.text)

但我犯了个错误:

SSLError: HTTPSConnectionPool(host='api.remove.bg', port=443): Max retries exceeded with url: /v1.0/removebg (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')])")))

你能告诉我这里发生了什么事吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49793
文章 [ 2 ]  |  最新文章 6 年前