Python Forum

Full Version: print (output)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so the below will print out the result of the show command. How do I get it to print out the show command prior to the result of the show command?

like i want it to print out "show ip int brief" prior to show ip int brief results
output = net_connect.send_command("show ip int brief")
print (output)
something like this?
output = net_connect.send_command("show ip int brief")
print(f'show ip int brief: {output}')
There are three ways:
command = "Hello World!"

print(f"my command is {command}")
print("my command is %s"%command)
print("my command is {}".format(command))
Output:
my command is Hello World! my command is Hello World! exe c:/Users/steve/Desktop/html/math/sdfdsdf.py my command is Hello World!
I use this one a lot for debugging programs too small to warrant logging.
print(f'{2**3 = }')
Output:
2**3 = 8
Not quite what you want since it prints the command, not the sent command.
print(f'{net_connect.send_command("show ip int brief") = }')
Output:
net_connect_send_command("show ip int brief") = whatever