format

概要Description

签名

s.format(*args, **kwargs): str

功能

按照 Python Format String Syntax 小语法 格式化字符串

打开 Python Format String Syntax

Python 官网

广告

案例Examples

正常情况

顺序填空
1 2 =
s = 'location is ({}, {})'result = s.format(3, 4)'location is (3, 4)'
指名填空
1 2 =
s = 'height: {h}, width: {w}'result = s.format(w=3, h=4)'height: 4, width: 3'
广告

ZZAX 微信公众

文档一更新,立刻告诉你