import urllib.request import json try: req = urllib.request.Request('http://localhost:8000/api/templates') with urllib.request.urlopen(req, timeout=5) as resp: data = json.loads(resp.read().decode('utf-8')) print('总数:', len(data)) models = sorted(set(t['machine_model'] for t in data)) print('机型:', models) types = sorted(set(t['template_type'] for t in data)) print('模板类型:', types) except Exception as e: print(f'Error: {e}')