The implementation code is as follows:
Attention:
1. String formatting
Print (' I ' m%s. I ' m%d year old '% (' Zhu ', 24)) is a template. %s is the first format character, which represents a string. %d is the second format character, which represents an integer. (' Zhu ', 24) Two elements replace the values of%s and%d, respectively
Print ("I ' m% (name) s. I ' m% (age) d years old "% {' name ': ' Zhu ', ' Age ': 24}) use a dictionary to pass real values. Two format characters are named. The name is used () enclosed. One key for each named corresponding dictionary
2. Abnormal
Multiple exceptions can be thrown in a try statement block try,,except,,except
else if no exception is thrown in the try block, the ELSE clause is executed
A finally clause, which is bound to be executed, regardless of whether an exception occurs in a try clause; the finally clause is commonly used at the end of a program to close a file or network socket
Applet 3: Read the file and print it out, if not present, prompt error message