Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. import requests
  2.  
  3. for url in ['https://api.github.com', 'https://api.github.com/invalid']:
  4. try:
  5. response = requests.get(url)
  6.  
  7. # If the response was successful, no Exception will be raised
  8. response.raise_for_status()
  9. except Exception as err:
  10. print(f'Other error occurred: {err}') # Python 3.6
  11. else:
  12. print('Success!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement