D
D
devcoahjr2022-03-05 01:34:31
Python
devcoahjr, 2022-03-05 01:34:31

How to write a variable to a text file and save it in a specific folder?

There is a variable response = requests.get(' jsonip.com ').json() which outputs {'ip': '46.36.80.48', 'geo-ip': ' https://getjsonip.com/#plus ', 'API Help': ' https://getjsonip.com/#docs '}
How can I write its output to a text file and save it?

response = requests.get('http://jsonip.com/').json()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kvason, 2022-03-05
@Kvason

f = open('text.txt', 'w')
f.write(response)
f.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question