% 是字符串格式化运算符或插值运算符。给定格式 % 值(其中格式是字符串),格式中的 % 转换说明符将被零个或多个值元素替换。其效果类似于使用 C 语言中的 sprintf()。例如,>>> lang = "Python" >>> print "%s is awesome!" % lang Python is awesome 你也可以使用此表示法格式化数字。例如,>>> cost = 128.527 >>> print "The book costs $%.2f at the bookstore" % cost The book costs $128.53 at the bookstore 你也可以使用字典来插值字符串。它们具有…… 阅读更多