静态方法的表示,在方法上方加上装饰@staticmethod
import requests class HTTP: @staticmethod # 把当前方法定为静态方法,把此方法封闭在请求类中是为了便于扩展 def get(url,return_json=True): r = requests.get(url) if r.status_code != 200: return {} if return_json else ‘‘ return r.json() if return_json else r.text
————————————————————————————————————————————————————————————
搜索需要外部数据源,也就是需要外部的API。
学习python-20191208(2)-Python Flask高级编程开发鱼书_第03章_数据与flask路由
原文:https://www.cnblogs.com/hzjdpawn/p/12006756.html