Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
伙计们,似乎不记得以以下格式显示 2 个或更多变量的正确语法:
log.debug ("%s %s " % hostname % processoutput[0])
谢谢!
你要
log.debug ("%s %s " % (hostname , processoutput[0]))
一个元组应该跟在 % 运算符之后,列出所有要格式化为字符串的参数。
log.debug("%s %s" % (hostname, processoutput[0]))
你也可以这样做:
log.debug('{0} {1}'.format(hostname, processoutput[0]))
乍一看,这可能看起来很复杂,但该format功能非常强大。请参阅文档和示例。
format