上QQ阅读APP看书,第一时间看更新
Exploring the main() function
The main() function is relatively simple. First, on line 48 we call the get_address() function and store the result in a variable named raw_account. This variable contains our JSON-formatted transaction data. In order to manipulate this data, we use the json.loads() function to deserialize the JSON data and store it in the account variable. At this point, our account variable is a series of dictionaries and lists that we can begin to traverse, which is exactly what we do in the print_transactions() function called on line 50:
042 def main(address):
043 """
044 The main function handles coordinating logic
045 :param address: The Bitcoin Address to lookup
046 :return: Nothing
047 """
048 raw_account = get_address(address)
049 account = json.loads(raw_account.read())
050 print_transactions(account)