我必须提取特定的多个值,如果可能的话,在一个文件中打印这些特定的值。
I tried the below code to do this
JSON value from URL is:
{'data': [{'value': '0.0.0.0'}, {'value': '0.0.0.1'}, {'value': '0.0.0.2'}]}
import requests
import json
url = 'https://www.example.com'
response = requests.get('url', headers=headers , verify=False)
json_data = json.loads(response.text)
value = json_data['data'][0]['value']
print (value)
output of this : 0.0.0.0
但我想在一个文件(.txt)中打印所有这些数值,如下所示。
0.0.0.0
0.0.0.1
0.0.0.3
请帮助我解决这个问题。