pythonpython-2.7telnetlib

How can put variable in tn.write?


I want to put a variable in script that i made

let's say

host = 192.168.1.1

and my comment in the script is :

tn.write("cpconf tohost=192.168.200.22:XXX \n")

my request : want that instead XXX the variable it is will be host

how can do it ? use Python2.7.


Solution

  • tn.write("cpconf tohost=192.168.200.22:{0} \n".format(host))
    

    Working! thanks