用python编写一个查询网页状态的代码

您可以使用 Python 内置的 requests 库来编写查询网页状态的代码。

下面是一个示例代码:

import requests

url ="https://www.example.com"

response = requests.get(url)

if response.status_code == 200:
    print(f"Successful: The website {url} is up and running!")
else:
    print(f"Unsuccessful: The website {url} returned status

你可能感兴趣的:(pycharm,ide,python)