[python][oldboy]字符串 format

#coding=utf8
def format(self, *args, **kwargs):  # known special case of str.format
    """
    S.format(*args, **kwargs) -> string

    Return a formatted version of S, using substitutions from args and kwargs.
    The substitutions are identified by braces ('{' and '}').
    """
    pass
test = 'liuzhipeng age = {age}, name = {name}, sex = {sex}'
print test
print test.format(age=10, name="liuzhipeng", sex="male")
原文地址:https://www.cnblogs.com/liuzhipenglove/p/7305898.html