Closed wshcdr closed 2 months ago
I followed sample codes like following //////////////// import httpx, json
deeplx_api = "http://127.0.0.1:1188/v1/translate"
data = { "text": "Hello World", "source_lang": "EN", "target_lang": "ZH" }
post_data = json.dumps(data) r = httpx.post(url = deeplx_api, data = post_data).text print(r)
/////////////////////// however, r is null
and I wrote my own //////////////////// import requests, json
url = "http://127.0.0.1:1188/translate"
data = { "text": "Hello world!", "source_lang": "EN", "target_lang": "ZH" } post_data = json.dumps(data)
response = requests.post(url, data=post_data)
dic = response.json() print(dic['data']) //////////////////// it worked fine, don't why?
pls read docs carefully.
I followed sample codes like following //////////////// import httpx, json
deeplx_api = "http://127.0.0.1:1188/v1/translate"
data = { "text": "Hello World", "source_lang": "EN", "target_lang": "ZH" }
post_data = json.dumps(data) r = httpx.post(url = deeplx_api, data = post_data).text print(r)
/////////////////////// however, r is null
and I wrote my own //////////////////// import requests, json
url = "http://127.0.0.1:1188/translate"
data = { "text": "Hello world!", "source_lang": "EN", "target_lang": "ZH" } post_data = json.dumps(data)
response = requests.post(url, data=post_data)
dic = response.json() print(dic['data']) //////////////////// it worked fine, don't why?