Learning Python for Forensics
上QQ阅读APP看书,第一时间看更新

Developing the print_output() function

The print_output() function defined on line 71 allows us to control how the data is displayed to the user. This function requires two strings as input that represent the USB name and date, as defined by the docstring. On line 78 and 79, we print the USB data using the .format() method. As discussed in Chapter 1, Now for Something Completely Different, this function replaces the curly brackets ({}) with the data provided in the method call. A simple example like this doesn't show off the full power of the .format() method. However, this function can allow us to perform complex string formatting with ease. After printing the input, execution returns to the called function where the script continues the next iteration of the loop, as follows:

071 def print_output(usb_name, usb_date):
072 """
073 Print the information discovered
074 :param usb_name: String USB Name to print
075 :param usb_date: String USB Date to print
076 :return: None
077 """
078 print('Device: {}'.format(usb_name))
079 print('First Install: {}'.format(usb_date))