Python String Formatting (%, .format() and f-string) for Network Automation

preview_player
Показать описание
In this video, I talk about string formatting (%, .format() and f-string) in Python. Below is the code I used in the video.

from netmiko import ConnectHandler

cisco_device = {
'device_type': 'cisco_ios_telnet',
'username': 'rviews',
}

connection = ConnectHandler(**cisco_device)

# 1. Using % formatting
print(filename_percent)

# 2. Using .format() method
print(filename_format)

# Using named placeholders with .format()
print("{device}_output:\n{cmd_output}".format(device=hostname, cmd_output=output))

# 3. Using f-strings
print(filename_fstring)

#pythonforbeginners #networkautomation #coding
Рекомендации по теме
visit shbcf.ru