in the process of learning flask, I encounter a strange problem. Maybe I am not good at learning skills. I hope the master will correct me
.-sharp
class ShuBook:
isbn_url = "http://t.yushu.im/v2/book/isbn/{}"
keyword_url = "http://t.yushu.im/v2/book/search?q={}&count={}&start={}"
@classmethod
def search_by_isbn(cls,isbn):
url = cls.isbn_url.format(isbn)
print(locals())
result = HTTP.get(url) -sharp resultdict json
print(locals()) -sharp------------------------
return result
@classmethod
def search_by_keyword(cls,keyword,count=15,start=0):
url = cls.keyword_url.format(keyword,count,start)
result = HTTP.get(url)
return result
-sharp HTTP
import requests
class HTTP:
@staticmethod
def get(self, url, return_json = True):
r = requests.get(url)
-sharp restful API
-sharp json
if r.status_code != 200:
return {} if return_json else ""
return r.json() if return_json else r.text
Program prompt error
get () missing 1 required positional argument: "url"
what is the reason why I should automatically apply the default parameter return_json = True, if I don"t set the second parameter here?
Thank you for correcting