hausaufgabe--python 34 - with and else

00-- In python, else can be used with if; while; try 

 

 

01-- using "with", we can open a file without f.close():

 

 

 

 

002-- make use of exception to make the codes simplier:

 

 Running result:

 

 

Another way:

 

posted @ 2017-08-31 04:18  ReedyLi  阅读(185)  评论(0编辑  收藏  举报