Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
string.Formatter允许使用自定义转换类型扩展新样式格式。
这对于旧式"%"格式字符串也可能吗?有这方面的图书馆吗?
"%"
也许
class CustomFormat(object): def __init__(self, obj): self.Object = obj def __str__(self): return str(self.Object).upper() # your magic goes here... print "abc%s" % customFormat("hello") # abcHELLO