1 # 用.format格式化字符串 2 "{} am {}".forma("I", "happy") 3 4 5 # 可以重复参数以节省时间 6 "{0} am {1}, {2} is {1}".format("I","happy","she") 7 8 # 如果不想通过数参数,可以用关键字 9 "{name} is hungry, and wants to eat {food}".format(name="Tom", food="fruit")
原文:https://www.cnblogs.com/shukeshu/p/14897807.html