标签:
Format strings contain “replacement fields” surrounded by curly braces {}
"First, thou shalt count to {0}" # References first positional argument "Bring me a {}" # Implicitly references the first positional argument "From {} to {}" # Same as "From {0} to {1}" "My quest is {name}" # References keyword argument ‘name‘ "Weight in tons {0.weight}" # ‘weight‘ attribute of first positional arg "Units destroyed: {players[0]}" # First element of keyword argument ‘players‘.
Two conversion flags are currently supported:‘!s‘
which callsstr()
on the value, and‘!r‘
which callsrepr()
.
标签:
原文地址:http://www.cnblogs.com/AngryZe/p/5966459.html