小编N R*_*awa的帖子

str.format_map(mapping)和str.format有什么区别

我不明白这个str.format_map(mapping)方法.我只知道它与str.format(*args, **kwargs)方法类似,你也可以传递字典作为参数(请参阅我的例子).例:

print ("Test: argument1={arg1} and argument2={arg2}".format_map({'arg1':"Hello",'arg2':123}))
Run Code Online (Sandbox Code Playgroud)

有人可以向我解释str.format_map(mapping)和str.format(*args, **kwargs)方法之间的区别,为什么我需要这个str.format_map(mapping) 方法?

python string string-formatting python-3.x

10
推荐指数
2
解决办法
2150
查看次数

标签 统计

python ×1

python-3.x ×1

string ×1

string-formatting ×1