Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 鸭形编码_Python_Api_Character Encoding_Duckling - Fatal编程技术网

Python 鸭形编码

Python 鸭形编码,python,api,character-encoding,duckling,Python,Api,Character Encoding,Duckling,我应用duckling来提取并将写的数字转换成数字。 当我用德语传递句子:“fünf sechs sieben”时,它触发了一个错误:{'message':'从上游服务器接收到无效响应” 你知道如何对句子进行编码以避免错误吗没有德语“umlauts”的句子很好用。 url = "https://duckling..../parse" payload = f'locale=de_DE&text={input_transcript}&dims=number' h

我应用duckling来提取并将写的数字转换成数字。 当我用德语传递句子:“fünf sechs sieben”时,它触发了一个错误:{'message':'从上游服务器接收到无效响应

你知道如何对句子进行编码以避免错误吗没有德语“umlauts”的句子很好用。

url = "https://duckling..../parse"

payload = f'locale=de_DE&text={input_transcript}&dims=number'
headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }

try:
        response = requests.post(
            url,
            data=payload,
            headers=headers,
        )
        if response.status_code == 200:
           json_response = response.json()


 

您是否尝试过对有效负载进行url编码?是的,如下所示:text.encode(encoding=“utf-8”).decode(encoding=“utf-8”),但这不起作用?谢谢!我应用了urllib.parse.quote进行编码,结果成功了!