- Learning Python for Forensics
- Preston Miller Chapin Bryce
- 207字
- 2021-08-20 10:17:14
The print_header() helper function
The print_header() helper function prints the account information to the console before transactions are printed. Specifically, the address, number of transactions, current balance, and total Bitcoins sent and received are displayed to the user. Take a look at the following code:
098 def print_header(account):
099 """
100 The print_header function prints overall header information
101 containing basic address information.
102 :param account: The JSON decoded account and transaction data
103 :return: Nothing
104 """
On lines 105 through 113, we print our values of interest using the string formatting method. During our program design, we chose to create this as a separate function in order to improve our code readability. Functionally, this code could have easily been, and originally was, in the print_transactions() function. It was separated to compartmentalize the different phases of execution. The purpose of the print statement on line 113 is to create a line of 22 left-aligned equal signs to visually separate the account information from the transactions in the console:
105 print('Address:', account['address'])
106 print('Current Balance: {:.8f} BTC'.format(
107 account['final_balance'] * 10**-8))
108 print('Total Sent: {:.8f} BTC'.format(
109 account['total_sent'] * 10**-8))
110 print('Total Received: {:.8f} BTC'.format(
111 account['total_received'] * 10**-8))
112 print('Number of Transactions:', account['n_tx'])
113 print('{:=^22}\n'.format(''))
- 網(wǎng)絡(luò)安全與管理
- CTF實(shí)戰(zhàn):技術(shù)、解題與進(jìn)階
- 科技安全:戰(zhàn)略實(shí)踐與展望
- 開(kāi)發(fā)者的Web安全戒律:真實(shí)威脅與防御實(shí)踐
- Penetration Testing with Perl
- 工業(yè)物聯(lián)網(wǎng)安全
- API攻防:Web API安全指南
- Python Penetration Testing Cookbook
- CTF競(jìng)賽權(quán)威指南(Pwn篇)
- Digital Forensics with Kali Linux
- API安全技術(shù)與實(shí)戰(zhàn)
- 數(shù)據(jù)安全架構(gòu)設(shè)計(jì)與實(shí)戰(zhàn)
- 數(shù)字政府網(wǎng)絡(luò)安全合規(guī)性建設(shè)指南:密碼應(yīng)用與數(shù)據(jù)安全
- Learn Azure Sentinel
- ATT&CK與威脅獵殺實(shí)戰(zhàn)