我想将路由器的输出写入文件。当我运行此代码时,我收到此错误消息,并且输出未写入文件。有没有人有解决问题的想法?
new_content = content.splitlines() AttributeError: 'dict' object has no attribute 'splitlines'
def get_config(task):
filename = task.host["dev_hostname"]+"_cmd_"+tstamp
if task.host.platform == "iosxr":
deploy_task = task.run(
task=napalm_get,
getters=["get_ntp_stats"],
)
task.host["get_ntp_stats"] = deploy_task.result
pathlib.Path("precheck").mkdir(exist_ok=True)
task.run(
task=write_file,
filename=f"precheck/{filename}.json",
content=task.host["get_ntp_stats"])