简体   繁体   English

将 api 导入到 jupyter 时出现问题

[英]issue with importing api to jupyter

import http.client

conn = http.client.HTTPSConnection(“farasa-api.qcri.org”) payload = “{\”text\”: \”هذا مثال بسيط\”}”

headers = { ‘content-type’: “application/json”, ‘cache-control’: “no-cache”, }

conn.request(“POST”, “/msa/webapi/lemma”, payload, headers)

res = conn.getresponse()

data = res.read()

print(data.decode(“utf-8”))

the result is showing as this结果显示如下

File "<ipython-input-61-b6148c5a04bb>", line 3
    conn = http.client.HTTPSConnection(“farasa-api.qcri.org”) payload = “{\”text\”: \”هذا مثال بسيط\”}”
                                             ^
SyntaxError: invalid character in identifier

can anyone help?谁能帮忙? I need to import this api.我需要导入这个 api。

Payload have to be under your conn and your double quote are "different" than normal:有效负载必须在您的 conn 之下,并且您的双引号与正常情况“不同”:

conn = http.client.HTTPSConnection("farasa-api.qcri.org") 

payload = "{\"text\": \"هذا مثال بسيط\"}"

headers = { 'content-type': "application/json", 'cache-control': "no-cache", }

conn.request("POST", "/msa/webapi/lemma", payload, headers)

res = conn.getresponse()

data = res.read()

print(data.decode("utf-8"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM