Русские видео

Сейчас в тренде

Иностранные видео


Скачать с ютуб Learn Nested Dictionaries in Python with Netmiko в хорошем качестве

Learn Nested Dictionaries in Python with Netmiko 6 месяцев назад


Если кнопки скачивания не загрузились НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу страницы.
Спасибо за использование сервиса savevideohd.ru



Learn Nested Dictionaries in Python with Netmiko

In this video, we will learn about nested dictionaries in Python. Below is the code I used in the video: A nested dictionary is a dictionary inside another dictionary. Key: A unique and immutable identifier (e.g., a string, number, or tuple). Value: Can be any data type (string, number, list, another dictionary, etc.). Structure: Key-value pairs are separated by a colon (:), and pairs are enclosed within curly braces ({}). Separator: Each key-value pair is separated by a comma (,). from pprint import pprint Initial Nested Dictionary device_data = { # Main dict "Router1": { # Nested dict for "Router1" "hostname": "R1", # Key-value pair "ip": "192.168.1.1", # Key-value pair } # End of nested dict } # End of main dict Create: Add new interface device_data["Router1"]["interfaces"] = { "Gig0/0": {"status": "up", "ip": "192.168.1.2"}, "Gig0/1": {"status": "down", "ip": None}, } Read: Access data print(device_data["Router1"]["hostname"]) print(device_data["Router1"]["interfaces"]["Gig0/0"]["ip"]) Update: Modify existing data device_data["Router1"]["ip"] = "192.168.1.2" device_data["Router1"]["interfaces"]["Gig0/1"]["status"] = "up" Delete: Remove data del device_data["Router1"]["interfaces"]["Gig0/1"] del device_data["Router1"]["ip"] Print final result print(device_data) #python #pythonforbeginners #networkautomation

Comments