xxxxxxxxxx
import requests
expected_code = 250
url = "http://example.com" # Replace with the actual URL
try:
response = requests.get(url)
response.raise_for_status() # Raise an exception if the response code is not the expected code
# Continue processing the response...
print("Request successful!")
except requests.exceptions.HTTPError as err:
print(f"Expected response code {expected_code} but got code {response.status_code}")
# Handle the error or raise it again if needed