I want to post my code result to an IoT Platform but whenever i'm trying to post the output it's giving me: ImportError: cannot import name 'post' from 'request' (C:\\Program Files\\Python37\\lib\\site-packages\\request__init__.py)
is it my package is unusable? or is there any other way to fix this error? here is my code
hasil = [2,1,1,1,1,2,2,2,1]
x = [3,4,2,5,3,4,3,7,6]
import request
from request import post
for e in range (0,len(x)):
if hasil ==1:
q = '{"\nStatus: Tidak Banjir"}'
o = json.dumps(q)
data = '\r\n{\r\n "m2m:cin": {\r\n "cnf": "message",\r\n "con": "\r\n {\r\n \t \\"Status\\": \\"'+str(o)+'\\",\r\n}}}'
url = 'https://platform.antares.id:8443/~/antares-cse/antares-id/FloodForecasting/WeatherData'
headers = {'cache-control':'no-cache','content-type':'application/json;ty=4','x-m2m-origin':'7c4f123fd1ba4737:3fc88dbc74b9c905'}
r = request.post(url,headers=headers,data=data)
elif hasil==2:
q = '{"\nStatus: Tidak Banjir"}'
o = json.dumps(q)
#print(o)
data = '\r\n{\r\n "m2m:cin": {\r\n "cnf": "message",\r\n "con": "\r\n {\r\n \t \\"Status\\": \\"'+str(o)+'\\",\r\n'
url = 'https://platform.antares.id:8443/~/antares-cse/antares-id/FloodForecasting/WeatherData'
headers = {'cache-control':'no-cache','content-type':'application/json;ty=4','x-m2m-origin':'7c4f123fd1ba4737:3fc88dbc74b9c905'}
r = request.post(url,headers=headers,data=data)
程序包名称是请求而不是请求。
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.