将:except IOError,e修改为except IOError as e 运行成功。
try:
f = open('blah','r')
except IOError as e:
print('could not open file:',e)
运行结果:
could not open file: [Errno 2] No such file or directory: 'blah'
将:except IOError,e修改为except IOError as e 运行成功。
try:
f = open('blah','r')
except IOError as e:
print('could not open file:',e)
运行结果:
could not open file: [Errno 2] No such file or directory: 'blah'