try: open("abc.txt",'r') print (aa) except Exception as msg: #或者写成except BaseException as msg: 定义了msg变量用于接收 print (msg) #异常信息,并通过print将其打印出来======================= RESTART: D:\Pythonwork\test.py ======================= [Errno 2] No such file or directory: 'abc.txt' >>> |
|
来自: Macalist > 《Python及其自动化》