好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python中format_map的使用

1、format_map只能在字符串格式使用可变数据参数来自字典等映射关系数据。

2、语法

str.format_map(mapping)

3、参数,mapping字典类型的数据。

4、返回格式化的字符串。

实例

weather = "晴天"
hours = 7
s = "今天天气是{weather},现在时间是{hours}点整"
s.format_map(vars())

以上就是python中format_map的使用,希望对大家有所帮助。

查看更多关于python中format_map的使用的详细内容...

  阅读:22次