import nacos import json import time SERVER_ADDRESSES = "127.0.0.1:8848" NAMESPACE = "7a91908a-7797-4866-9b1e-3b6cd16b3050" # 这里是namespace的id # no auth mode # client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE) # auth mode client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, username="nacos", password="nacos") # get config data_id = "user-srv.json" group = "dev" # 返回结果为字符串 conf = client.get_config(data_id, group) print(conf) ld = json.loads(conf) print(ld["name"]) def test_cb(args): print(args) if __name__ == "__main__": client.add_config_watcher(data_id, group, test_cb) time.sleep(3000)