如何使用 'routeros' 库在 Python 中访问 RouterOS API(最小示例)

此示例使用来自 PyPI (GitHub) 的 routeros 库访问 MikroTik API 并提取系统标识。

routeros_minimal_example.py
#!/usr/bin/env python3
from routeros import login

routeros = login('admin', 'abc123abc', '192.168.88.1')

output = routeros('/system/identity/print')
# Extract the one identity string from the list of dictionaries
print(output[0]['name'])

Check out similar posts by category: MikroTik, Python