Python 代码:查询教室空闲时间
这个 Python 代码使用 'requests' 库发送 HTTP GET 请求到一个返回 JSON 数据的 URL。代码通过 'if' 语句检查教室在不同时间段的可用性,并打印结果。
import requests
cookies = {
'JSESSIONID': '979EB8A4FB45297AA14D52989E787062',
}
coursetime = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
response = requests.get('http://jwcwx.nepu.edu.cn/free-class-room/classroomUsedData?jwCode=内容:2018194&buildCode=1&roomCode=101', cookies=cookies)
data = response.json()
for i in coursetime:
if data[i]['status'] == '1':
print('The classroom is available at ' + i + 'th class time.')
else:
print('The classroom is not available at ' + i + 'th class time.')
原文地址: https://www.cveoy.top/t/topic/neob 著作权归作者所有。请勿转载和采集!