Reputation: 11
How i can fix it? What I can to do with this error?
https://github.com/dandayo/formyhoneygirl/blob/main/main.py
def link():
with open('data.json', 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=4)
with open('data.json', 'r', encoding='utf-8') as s:
image_url = json.load(s)
print(image_url["url"])
filelName = link.split("/")[-1]+".jpg"
answer = requests.get(link, stream=True)
Upvotes: 0
Views: 1180
Reputation: 160
First of all, please let us know where the error occurs next time, it will make it easier to answer your question.
The issue seems to be with the fact that you are... well.. Indeed calling the function itself and trying to split it, which understandably throws the error. There are 2 things that are wrong with your code:
You're not returning anything from the function. Use return image_url['url']
instead of print. Right now all you're doing is simply printing the value to the console and that's it. Your function returns None
.
You're using link.split()
, when you should be calling the function by using link().split()
.
Upvotes: 1
Reputation: 1388
link
is a function, which incidentally returns nothing.
split
splits nstrings.
link.split("/")
tries to split the function.
Hence, the error.
Upvotes: 1