简体   繁体   English

用于从Blockchain JSON中提取数据的Python脚本

[英]Python Script to pull data from Blockchain JSON

I am trying to write a python script that will take a bitcoin address and show how many transactions have processed against that address. 我正在尝试编写一个python脚本,它将获取一个比特币地址,并显示已针对该地址处理了多少交易。 I can pull the JSON data down and print it to the screen but I can not figure out how to actually make it so that I go into that data and pull out "n_tx" potion. 我可以将JSON数据拉下来并将其打印到屏幕上,但我无法弄清楚如何实际制作它以便我进入该数据并拉出“n_tx”药水。 Here is what I have so far, basic but it shows I am pulling the right data. 这是我到目前为止所做的,基本但它显示我正在提取正确的数据。

import requests
import json

r = requests.get('http://blockchain.info/rawaddr/1MtKaahhBAwc1Bs9JLgh2tTAmvHL4kauRb')

print r.json()

I have read several tutorials and tried lots of different ideas and I am sure it is a simple fix my brain just can't grasp it today. 我已经阅读了几个教程并尝试了很多不同的想法,我相信这是一个简单的修复我的大脑今天无法掌握它。

Ultimately I would like to end up with the following on my screen: 1MtKaahhBAwc1Bs9JLgh2tTAmvHL4kauRb has 0 transactions 最终我想在我的屏幕上看到以下内容:1MtKaahhBAwc1Bs9JLgh2tTAmvHL4kauRb有0笔交易

Thanks in advance. 提前致谢。

你的意思是这样的吗?

print r.json()['address'],' has ', r.json()['n_tx'], 'transactions'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM