官术网_书友最值得收藏!

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))
主站蜘蛛池模板: 昂仁县| 兰坪| 南充市| 宁阳县| 庆城县| 沙洋县| 淳化县| 丹巴县| 涞水县| 陈巴尔虎旗| 金平| 定兴县| 北辰区| 图们市| 罗山县| 密山市| 大田县| 齐齐哈尔市| 凌海市| 张北县| 德江县| 安岳县| 肃南| 德阳市| 江西省| 和顺县| 延川县| 高要市| 孝义市| 教育| 施秉县| 宁海县| 山丹县| 武清区| 微山县| 日土县| 遂川县| 江门市| 新和县| 青浦区| 贞丰县|