demo_httpx_sync.py 339 B

1234567891011121314
  1. # -*- coding: utf-8 -*-
  2. import httpx
  3. def sync_get_example():
  4. # 使用 httpx 发送 GET 请求
  5. response = httpx.get('https://httpbin.org/get')
  6. # 打印状态码和响应内容
  7. print(f"Status Code: {response.status_code}")
  8. print(f"Response Content: {response.text}")
  9. if __name__ == "__main__":
  10. sync_get_example()