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

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))
主站蜘蛛池模板: 卢龙县| 黔西县| 大同市| 武功县| 曲沃县| 志丹县| 靖安县| 凤冈县| 鲁山县| 万全县| 华蓥市| 七台河市| 麻阳| 砀山县| 北碚区| 巴塘县| 崇礼县| 宁乡县| 富平县| 武义县| 潮州市| 余庆县| 彰化县| 曲周县| 海门市| 新绛县| 海阳市| 齐河县| 荣昌县| 民县| 海安县| 彩票| 海原县| 华蓥市| 和硕县| 定西市| 炎陵县| 额尔古纳市| 抚顺县| 囊谦县| 竹溪县|