最佳答案
在 Python 中,生成格式化输出似乎有两种不同的方式:
user = "Alex"
number = 38746
print("%s asked %d questions on stackoverflow.com" % (user, number))
print("{0} asked {1} questions on stackoverflow.com".format(user, number))
有没有一种方法比另一种更受欢迎?它们是等价的吗,有什么区别吗?应该使用什么形式,尤其是 Python 3?