Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Handling Exceptions

for arg in sys.argv[1:]:
    try:
        f = open(arg, 'r')
    except IOError:
        print('cannot open', arg)
    else:
        print(arg, 'has', len(f.readlines()), 'lines')
        f.close()
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #Handling #Exceptions
ADD COMMENT
Topic
Name
3+9 =