I have a problem to parse the "data" to data in curl command
curl -H "Content-Type: application/json" -X POST -d '{"data":"traffic cun cun je"}' http://68.xxx.236.113/api/
Above is my curl command. And after I use, https://curl.trillworks.com/ to convert curl command to Python, I got this
import requests
headers = {
'Content-Type': 'application/json',
}
data = '{"data":"traffic cun cun je"}'
response = requests.post('http://68.xxx.236.113/api/', headers=headers, data=data)
The problem is, how can I change the "data":"CHANGE HERE"
with the data in a list (text)
Below is my code for the list:
with open('hai.json') as f:
data = json.load(f)
for line in data:
text=line['text']
loc=line['location']
i.append(text)
u.append(loc)