Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Using a generic exception block

#!/usr/bin/env python3

try:
    with open('input.txt', 'r') as myfile:
        for line in  myfile:
            print(line)
except FileNotFoundError:
    print('Sorry, file doesn't exist or you don't have permission to access the file')
except Exception as error:
    print(error)
    print(type(error))

print('Outside the with block')
Comment

PREVIOUS NEXT
Code Example
Python :: Freqtrade - sell after x candels 
Python :: save multiple df to pkl 
Python :: Arduino - Send Commands with Serial Communication with python 
Python :: COLLECTING 
Python :: not mutable data type in python 
Python :: pyyhon SHA512 hash with key 
Python :: dataset analysis in python photo photoelectric effect 
Python :: client.futures exchange info() 
Python :: tanimoto coefficient rdkit 
Python :: import cmath python 3 
Python :: .lowertkinter 
Python :: requests session 
Python :: python numpy 
Python :: create a dictionary from dataframe 
Python :: enumerate function in python for loop 
Python :: string -1 python 
Python :: python merge sort 
Python :: pandas add time to datetime 
Python :: create set in python 
Python :: pandas 
Python :: padding figures in python 
Python :: select python interpreter vscode 
Python :: python editor online 
Python :: prime numbers 1 to 100 
Python :: list slicing reverse python 
Python :: how to read mysql table in python 
Python :: python input - how to read a number 
Python :: python tokens 
Python :: what is heapq in python 
Python :: python vrer un fichier texte 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =