python 中requests的返回数可直接使用json

对Python的request不是很了解,在使用时才发现,可以把request的请求结果,直接使用.json()['字段名']方法进行一个取值,案例如下

    def test_tiantian(self):
        data = "type=tiantian&postid=11111111111"
        result = requests.get(url=self.url, params=data,headers=self.headers1 )

        print(result.url)
        print(result.text)
        print("************")
        print(result.json()['ischeck'])

 

转载于:https://www.cnblogs.com/chongyou/p/11507411.html