Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this question# Dependencies
import json
import requests
# Specify the URL
url = ""
# Make request and store response
r = requests.get(url)
print("Status code:", r.status_code)
response_dict = r.json()
keys = {"setup", "punchline"}
for item in response_dict:
for key, value in item.items():
if key in keys:
print(key, " : ", value)
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this question# Dependencies
import json
import requests
# Specify the URL
url = "https://official-joke-api.appspot/jokes/programming/ten"
# Make request and store response
r = requests.get(url)
print("Status code:", r.status_code)
response_dict = r.json()
keys = {"setup", "punchline"}
for item in response_dict:
for key, value in item.items():
if key in keys:
print(key, " : ", value)
Share
Improve this question
asked Jan 5, 2020 at 0:16
Paa AmoakoPaa Amoako
1
1
- Sorry, but you just posted a wall of code. Can you explain (by editing the question itself): What is it you're trying to achieve? What have you tried so far? Where exactly are you having problems? And please keep in mind, this community is specific to WordPress. So try to answer all these questions in regard to (the latest) WP please. – kero Commented Jan 5, 2020 at 2:47
1 Answer
Reset to default 1It's off-topic but if you just want to write the setup and punchline values to a text file you can do something like this:
# Dependencies
import json
import requests
# Specify the URL
url = "https://official-joke-api.appspot/jokes/programming/ten"
# Make request and store response
r = requests.get(url)
print("Status code:", r.status_code)
jokes = json.loads(r.text)
with open("outfile.txt", "w") as f:
for joke in jokes:
f.write("{}:{}\n".format(joke["setup"], joke["punchline"]))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744859522a4597614.html
评论列表(0条)