import requests import json class Run_main(): def __init__(self, url, method, data=None): self.re = self.run_main(url, method, data=None) def send_get(self, url, data): re = requests.get(url, data).json() return json.dumps(re, indent=2, sort_keys=True) def send_post(self,url, data): re = requests.post(url, data).json() return json.dumps(re, indent=2, sort_keys=True) def run_main(self, url, method, data=None): res = None if method == ‘GET‘: res = self.send_get(url, data) else: res = self.send_post(url, data) return res if __name__ == ‘__main__‘: url = ‘‘ data = { ‘marking‘: ‘‘, ‘secrect‘: ‘‘, ‘timestamp‘: ‘‘, ‘token‘: ‘‘, ‘uid‘: ‘0‘ } runner = Run_main(url, ‘POST‘, data) print(runner.re)
原文:https://www.cnblogs.com/dudubao/p/9557624.html