python2
python 2 必须加object加入后是新式类 python 2 不加object是经典类 class HTTP(object): # 经典类和新式类 @staticmethod def get(url,return_json = True): r = requests.get(url) #restful #json if r.status_code != 200: return {} if return_json else ‘‘ return r.json() if return_json else r.text Python3 无需增加object就是新式类 class HTTP(): # 经典类和新式类 @staticmethod def get(url,return_json = True): r = requests.get(url) #restful #json if r.status_code != 200: return {} if return_json else ‘‘ return r.json() if return_json else r.text
原文地址:https://www.cnblogs.com/zhaoyingjie/p/9068632.html
时间: 2024-11-06 07:39:27