maco1717 maco1717 - 1 year ago 112
Python Question

Python print result several variables/functions on same line

I'm trying to print time stamp and a socket peer name...

this Python thing is not intuitive at all, I've been trying different version but in essence what i've tried is something like this:

print time.strftime("%X") " - " socket.getpeername())

I want to print "time - address" from clients connecting (sending request) to my HTTP server...

In essence what im trying to do is print 2 variables (function calls) with a string in between.

any suggestions on how to implement this?

Answer Source
now  = time.strftime("%X")
peer = socket.getpeername()
print("{} - {}".format(now, peer))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download