• 字符串类型的格式化

    <模板字符串>.format(<逗号分隔的参数>)

    1. '你好{} 世界{}'.format('hello','world')# 不带字段,依顺序匹配
    2. # 你好hello 世界world
    3. '你好{0} 世界{1}'.format('hello','world')# 带数字,按数字顺序匹配
    4. # 你好hello 世界world
    5. '你好{1} 世界{0}'.format('hello','world')# 打乱顺序,带数字,按数字顺序匹配
    6. #你好world 世界hello
    7. '你好{a} 世界{b} 你好世界{a}'.format(b='hello',a='world') # 带关键字
    8. #你好world 世界hello 你好世界world
    9. print('%d*%d=%d'%(j,i,j*i),end=' ')