บทเรียนบูรณาการ
กำลังโหลดข้อมูล…
AQI คือเส้นตรงเป็นช่วง ๆ
ค่ากลางและการกระจาย
ทุกสถานี 7 วัน
สองค่าไปด้วยกันไหม
สถานีห่างกันเท่าไร
อ่านระดับแล้วควรทำอะไร
| ระดับ | PM2.5 (AQI) | ควรทำ |
|---|
เขียนโปรแกรมอ่านค่าฝุ่นจริง
import requests
url = "https://tb1.ac.th/tak-aqm/integration_lessons.php?api=latest"
stations = requests.get(url, timeout=10).json()
for s in stations:
if s["aqi_ready"]:
pm = round(float(s["pm25_24h"]), 1)
print(s["station_name"], pm, "AQI", s["aqi_thai"])
ผลลัพธ์ถ้ารันตอนนี้
กำลังโหลด…