Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print (output)
#1
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)
buran write Sep-03-2021, 08:23 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
something like this?
output = net_connect.send_command("show ip int brief")
print(f'show ip int brief: {output}')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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!
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,033 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  How to output one value per request of the CSV and print it in another func? Student44 3 1,278 Nov-11-2022, 10:45 PM
Last Post: snippsat
  How to print the output of a defined function bshoushtarian 4 1,236 Sep-08-2022, 01:44 PM
Last Post: deanhystad
Sad Want to Save Print output in csv file Rasedul 5 10,687 Jan-11-2022, 07:04 PM
Last Post: snippsat
Photo print output none 3lnyn0 4 1,756 Nov-01-2021, 08:46 PM
Last Post: 3lnyn0
  output correction using print() function afefDXCTN 3 10,961 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx
  print function output wrong with strings. mposwal 5 3,044 Feb-12-2021, 09:04 AM
Last Post: DPaul
  Print output not working xninhox 7 3,941 Jan-16-2021, 09:42 AM
Last Post: xninhox
  Output with none, print(x) in function Vidar567 3 2,451 Nov-24-2020, 05:40 PM
Last Post: deanhystad
  Print output in single file using pramika loop deepakkhw 1 2,036 Jul-11-2020, 11:57 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020