maco1717 maco1717 - 2 months ago 5x
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?

now  = time.strftime("%X")
peer = socket.getpeername()
print("{} - {}".format(now, peer))