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

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))
主站蜘蛛池模板: 武鸣县| 正镶白旗| 鹰潭市| 佛坪县| 阿图什市| 藁城市| 卢龙县| 葵青区| 红原县| 恩施市| 菏泽市| 怀柔区| 花垣县| 交城县| 皋兰县| 广丰县| 阿瓦提县| 古田县| 墨江| 望城县| 故城县| 陆丰市| 新巴尔虎左旗| 饶阳县| 姚安县| 满洲里市| 新余市| 大余县| 黄冈市| 高陵县| 固始县| 封开县| 外汇| 牡丹江市| 应城市| 开江县| 井研县| 台湾省| 五家渠市| 图木舒克市| 河津市|