Answer the question
In order to leave comments, you need to log in
Write changed data from json to txt file?
r = requests.get('https://poloniex.com/public?command=returnTicker') #биток
r.json()
data = r.json()
x1 = data['USDT_BTC']['last']
r2 = requests.get('http://whattomine.com/coins.json?utf8=%E2%9C%93&commit=Calculateð=true&factor%5Beth_hr%5D='+str(user.name))
r2.json()
d2 = r2.json(object_pairs_hook=OrderedDict)
f = open("result.txt",'w')
for i in d2['coins']:
btc = d2['coins'][i]['btc_revenue24']
pr = float(x1)*float(btc)
f.writelines(i + '\n' + d2['coins'][i]['tag'][:4] + ': '+ d2['coins'][i]['estimated_rewards24'] + ' BTC: ' + d2['coins'][i]['btc_revenue24'] + ' Profit: ' + "%.2f" % float(pr) + '$' + '\n' for i in d2['coins'])
f.close()
Answer the question
In order to leave comments, you need to log in
I didn’t quite understand, why would he execute writelines () more than once? The call is not in a loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question