Python Tutorial: Tabulate Library- Print dictionary data in table format | Network Automation

NetworkEvolution
NetworkEvolution
1.3 هزار بار بازدید - 11 ماه پیش - #networkautomation
#networkautomation #networkengineers #tabulate

𝑳𝒆𝒂𝒓𝒏 𝒕𝒐 𝑨𝒖𝒕𝒐𝒎𝒂𝒕𝒆 𝒚𝒐𝒖𝒓 𝑵𝒆𝒕𝒘𝒐𝒓𝒌 𝑰𝒏𝒇𝒓𝒂𝒔𝒕𝒓𝒖𝒄𝒕𝒖𝒓𝒆 𝒇𝒓𝒐𝒎 𝑺𝒄𝒓𝒂𝒕𝒄𝒉:

𝑵𝒆𝒕𝒎𝒊𝒌𝒐, 𝑷𝒂𝒓𝒂𝒎𝒊𝒌𝒐, 𝑺𝑺𝑯, 𝑵𝒐𝒓𝒏𝒊𝒓, 𝑷𝒚𝑨𝑻𝑺, 𝑵𝑨𝑷𝑨𝑳𝑴,  𝑵𝑬𝑻𝑪𝑶𝑵𝑭, 𝑹𝑬𝑺𝑻𝑪𝑶𝑵𝑭, 𝒀𝑨𝑵𝑮 𝑴𝒐𝒅𝒆𝒍, 𝑹𝑬𝑺𝑻-𝑨𝑷𝑰, 𝑵𝑿-𝑨𝑷𝑰 𝑨𝒖𝒕𝒐𝒎𝒂𝒕𝒊𝒐𝒏𝒔.
Unlock the Power of Network Automation: Enroll in our Comprehensive Udemy Course Today
https://www.udemy.com/course/python-f...

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗣𝘆𝘁𝗵𝗼𝗻 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗡𝗲𝘁𝘄𝗼𝗿𝗸 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝘀(𝟭𝟮𝟬+ 𝗩𝗶𝗱𝗲𝗼𝘀)
Welcome to NetworkEvolution !!

☸𝗣𝗹𝗲𝗮𝘀𝗲 𝗳𝗼𝗹𝗹𝗼𝘄 𝗯𝗲𝗹𝗼𝘄 𝗚𝗶𝘁𝗛𝘂𝗯 𝗣𝗮𝗴𝗲 𝗳𝗼𝗿 𝘁𝗵𝗲 𝗹𝗮𝘁𝗲𝘀𝘁 𝗰𝗼𝗱𝗲𝘀:
https://github.com/network-evolution

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗖𝗶𝘀𝗰𝗼 𝗡𝗫𝗔𝗣𝗜-𝗖𝗟𝗜 𝗣𝘆𝘁𝗵𝗼𝗻 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻: 𝗡𝗲𝘅𝘂𝘀 𝟵𝗸 :𝗣𝗮𝗿𝘀𝗲 𝗷𝘀𝗼𝗻 𝗫𝗠𝗟 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗗𝗮𝘁𝗮
Cisco Nexus 9K installation and API s...

𝗣𝗹𝗮𝘆𝗹𝗶𝘀𝘁: 𝗟𝗲𝗮𝗿𝗻 𝘁𝗼 𝗣𝗮𝗿𝘀𝗲 𝗖𝗶𝘀𝗰𝗼 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝘂𝘀𝗶𝗻𝗴 𝗣𝘆𝘁𝗵𝗼𝗻 𝗥𝗲𝗴𝗘𝘅:𝗿𝗲 𝗧𝘂𝘁𝗼𝗿𝗶𝗮𝗹(𝟭𝟱+ 𝗩𝗶𝗱𝗲𝗼𝘀)
Learn to write your own RegEx Parser ...

In this tutorial we will see how to create tables in terminal using python tabulate library
tables and header in python terminal
print table in python
create tables from python lists and dictionaries
python table creation beginner tutorial
python for network engineers
python for network automation
convert list and dictionaries to tables
create tabular data using python and print to the user
create user friendly tables in python
python-tabulate tutorial
guide to use tabulate
pip install tabulate
covert data types to tables in python
cteate multiple table format
grid fancy-grid format
python dictionary to grid table
from tabulate import tabulate
fancy_grid example tabulate
sort items in table using python tabulate
python itemgetters
sort dictionary using item getter
how tot get data using itemgetter

#########
script

from tabulate import tabulate
from operator import itemgetter
tabulate ()


interface_list = [
   {'name': 'Gi1',
    'ip': '192.168.1.1',
    'mask': '255.255.255.0'},
   {'name': 'Gi2',
    'ip': '192.168.1.2',
    'mask': '255.255.255.0'},
   {'name': 'Gi3',
    'ip': '192.168.1.3',
    'mask': '255.255.255.0'},
   {'ip': '192.168.1.0',
       'name': 'Gi4',
    'mask': '255.255.255.0'},
]
dict_getter = itemgetter("ip")
interface_list.sort(key=dict_getter)
print(tabulate(interface_list, tablefmt='fancy_grid'))

hdr = ['Name', 'IP', "Mask"]
value_list = []
for intf in interface_list:
   value_list.append(list(intf.values()))

print(value_list)
print(tabulate(value_list, headers=hdr, tablefmt="fancy_grid"))
11 ماه پیش در تاریخ 1402/06/05 منتشر شده است.
1,328 بـار بازدید شده
... بیشتر