如何将变量放入tn.write?

How can put variable in tn.write?

我想在我制作的脚本中放置一个变量

假设

host = 192.168.1.1

我在脚本中的评论是:

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

我的要求: 想要 XXX 变量将是 host

怎么办? 使用 Python2.7.

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

工作中!谢谢