简体   繁体   中英

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.

Payload have to be under your conn and your double quote are "different" than normal:

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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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