long_str = ("This is a long %s" % "story." "And you are welcome to %s." % "listen")
是没有语法错误的。 然后,
long_str = ("It is %d stories." % 3 )
也是没问题的。 最后,
long_str = ("我编不下去了,随便搞%d 个测试" % 123 "这是一个%s 测试啊" % "有趣的")
就是说这种方式来组合字符串, % 后的元素穿插在中间的,只能是字符串,其他类型元素,只能安排在最后。 不然会报语法错误。大家知道是那部分的 python 文档解释到吗?