[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")

 

posted @ 2017-08-08 11:16  liuzhipenglove  阅读(114)  评论(0编辑  收藏  举报