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

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))
主站蜘蛛池模板: 贞丰县| 延吉市| 鹰潭市| 措美县| 乌兰浩特市| 台湾省| 增城市| 汝南县| 平凉市| 莱州市| 天台县| 高邮市| 灌阳县| 财经| 永德县| 富顺县| 昌吉市| 祥云县| 宜宾市| 西昌市| 吉水县| 克拉玛依市| 普宁市| 和田市| 康保县| 凌云县| 专栏| 新宁县| 囊谦县| 靖江市| 永新县| 漯河市| 南溪县| 固原市| 仁布县| 昭通市| 奉节县| 博野县| 奉贤区| 香河县| 合作市|