Python Forum
print (output) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: print (output) (/thread-34815.html)



print (output) - taaperaban - Sep-03-2021

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)



RE: print (output) - buran - Sep-03-2021

something like this?
output = net_connect.send_command("show ip int brief")
print(f'show ip int brief: {output}')



RE: print (output) - naughtyCat - Sep-03-2021

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!



RE: print (output) - deanhystad - Sep-03-2021

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