初级
查询传感器指标类型与解析格式
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
st_csv = open_url("https://data.zuihe.com/dbd/ms-devhub/state_00/sensor_types.csv").read()
st = pd.read_csv(StringIO(st_csv))
print("Sensor types:")
for _, row in st.iterrows():
rng = "[" + str(row['min_value']) + "," + str(row['max_value']) + "]" + row['unit']
fmt = row['parse_format']
print(" " + row['metric'] + ": " + rng + " format=" + fmt)
binary_types = st[st['parse_format']=='binary_struct']
print("Binary struct types: " + str(list(binary_types['metric'])))
示例
输入
solve()
期望输出
Sensor types: cpu_temp: [20.0,90.0]°C format=json_field temperature: [-40.0,125.0]°C format=compact_abbrev humidity: [0.0,100.0]% format=compact_abbrev pressure: [800.0,1200.0]hPa format=binary_struct vibration_rms: [0.0,50.0]mm/s² format=binary_struct light: [0.0,100000.0]lux format=compact_abbrev mem_free: [0.0,4096.0]MB format=json_field cpu_usage: [0.0,100.0]% format=json_field voltage: [200.0,250.0]V format=binary_struct current: [0.0,100.0]A format=binary_struct co2: [400.0,5000.0]ppm format=json_field noise: [30.0,120.0]dB format=json_field Binary struct types: ['pressure', 'vibration_rms', 'voltage', 'current']
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199