ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

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

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Learn Nested Dictionaries in Python with Netmiko

cisco

ccna

ccnp

ccie

python

network automation

Автор: Ferds Tech Channel

Загружено: 2024-12-16

Просмотров: 44

Описание: 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

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Learn Nested Dictionaries in Python with Netmiko

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Learn Python Sets for Network Automation

Learn Python Sets for Network Automation

Python - Accessing Nested Dictionary Keys

Python - Accessing Nested Dictionary Keys

Python dictionaries are easy 📙

Python dictionaries are easy 📙

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

ЗА ПЕРЕВОДЫ на карту начали БЛОКИРОВАТЬ! Как избежать блокировки карты в 2025. НОВЫЕ правила

ЗА ПЕРЕВОДЫ на карту начали БЛОКИРОВАТЬ! Как избежать блокировки карты в 2025. НОВЫЕ правила

Cisco IOS - Ansible Automated Configuration Rollback

Cisco IOS - Ansible Automated Configuration Rollback

«Жить надо сегодня». Олег Тиньков и Майкл Калви о взлете нового финтех-стартапа Plata

«Жить надо сегодня». Олег Тиньков и Майкл Калви о взлете нового финтех-стартапа Plata

КАК УСТРОЕН TCP/IP?

КАК УСТРОЕН TCP/IP?

Алгоритмы на Python 3. Лекция №1

Алгоритмы на Python 3. Лекция №1

Маша и Медведь 💥 НОВАЯ СЕРИЯ! 💥 Книжка-лягушка 🧙‍♀️📚🐸 Коллекция мультиков про Машу

Маша и Медведь 💥 НОВАЯ СЕРИЯ! 💥 Книжка-лягушка 🧙‍♀️📚🐸 Коллекция мультиков про Машу

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]