隐藏

Python调用WebAPI

发布:2023/10/22 21:47:07作者:管理员 来源:本站 浏览次数:407

import requests
import json
#get
url1="http://localhost:5045/Health/Hi"
res = requests.get(url=url1)
print(res.text)
#post
url2="http://localhost:5045/Health/GetProfile"
textmod = {'Id':'1'}
res = requests.post(url2,data=json.dumps(textmod), headers={'content-type': 'application/json;charset=UTF-8'})
print(res.text)