中级
实现设备资源HATEOAS链接
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd, json
devs_csv = open_url(____).read()
devs = pd.read_csv(StringIO(____))
def device_with_links(____):
did = row['____']
base = f'____'
obj = row[['____','____','____','____']].to_dict()
obj['____'] = {'____':{'____':base},'____':{'____':f'____','____':'____'},
'____':{'____':f'____'},'____':{'____':f'____'}}
return obj
for _, row in devs.head(____).iterrows():
print(json.dumps(device_with_links(____), ensure_ascii=False, indent=____))
示例
输入
solve()
期望输出
{
"device_id": "DEV001",
"device_name": "A车间温湿度-01",
"device_type": "temperature",
"status": "online",
"_links": {
"self": {
"href": "/api/v1/devices/DEV001"
},
"data": {
"href": "/api/v1/devices/DEV001/data",
"method": "POST"
},
"status": {
"href": "/api/v1/devices/DEV001/status"
},
"commands": {
"href": "/api/v1/devices/DEV001/commands"
}
}
}
{
"device_id": "DEV002",
"device_name": "A车间温湿度-02",
"device_type": "temperature",
"status": "online",
"_links": {
"self": {
"href": "/api/v1/devices/DEV002"
},
"data": {
"href": "/api/v1/devices/DEV002/data",
"method": "POST"
},
"status": {
"href": "/api/v1/devices/DEV002/status"
},
"commands": {
"href": "/api/v1/devices/DEV002/commands"
}
}
}
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199