DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
<address>
<ip>192.168.55.3</ip>
<netmask>255.255.255.0</netmask>
</address>
</ipv4>
</interface>

To write these changes back to your original file, you can
use the following code:


Click here to view code image


with open("xml_sample.xml", "w") as data:
data.write(xmltodict.unparse(xml_dict,
pretty=True))

YAML Ain’t Markup Language (YAML)


YAML is an extremely popular human-readable format
for constructing configuration files and storing data. It
was built for the same use cases as XML but has a much
simpler syntax and structure. It uses Python-like
indentation to differentiate blocks of information and
was actually built based on JSON syntax but with a
whole host of features that are unavailable in JSON (such
as comments). If you have ever used Docker or
Kubernetes, you have undoubtably run into YAML files.
The following is an example of YAML:


Click here to view code image


---
interface:
name: GigabitEthernet2
description: Wide Area Network
enabled: true
ipv4:
address:


  • ip: 172.16.0.2
    netmask: 255.255.255.0

Free download pdf