why-pip.md
· 389 B · Markdown
Raw
```python
import requests
def get_data():
url = "https://jsonplaceholder.typicode.com/posts/1"
response = requests.get(url)
if response.status_code == 200:
print("Data retrieved successfully:")
print(response.json())
else:
print("Failed to retrieve data. Status code:", response.status_code)
if __name__ == "__main__":
get_data()
```
import requests
def get_data():
url = "https://jsonplaceholder.typicode.com/posts/1"
response = requests.get(url)
if response.status_code == 200:
print("Data retrieved successfully:")
print(response.json())
else:
print("Failed to retrieve data. Status code:", response.status_code)
if __name__ == "__main__":
get_data()