Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- for url in ['https://api.github.com', 'https://api.github.com/invalid']:
- try:
- response = requests.get(url)
- # If the response was successful, no Exception will be raised
- response.raise_for_status()
- except Exception as err:
- print(f'Other error occurred: {err}') # Python 3.6
- else:
- print('Success!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement