Python Exception Handling IOError -


i'm trying write simple pything code try open file not exist, handle exception buy displaying "cannot open, no such directory or file" suggestions on i'm doing incorrect?

import sys  try:      f = open("h:\\nosuchdirectory\\nosuchfile.txt","w") # not modify line  except ioerror:     print('cannot open, no such directory or file')  f.write("this grape file") # not modify line  f.close() # not modify line 

the initial piece of code started is:

f = open("h:\\nosuchdirectory\\nosuchfile.txt","w" # not modify line  f.write("this grape file") # not modify line  f.close() # not modify line 


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -