python中var是什么_这是什么代码:%(var)s?也许是Python?

类似于%s。括号内的部分是可选的。在The only difference is that, for the first one, your values must be a

tuple with exactly the number of items specified by the format string,

and for the 2nd one, it must be a single mapping object (for example,

a dictionary)A conversion specifier contains two or more characters and has the

following components, which must occur in this order:The '%' character, which marks the start of the specifier.

Mapping key (optional), consisting of a parenthesised sequence of characters (for

example, (somename)).

.. and there are some more

同时:When the right argument is a dictionary (or other mapping type), then

the formats in the string must include a parenthesised mapping key

into that dictionary inserted immediately after the '%' character. The

mapping key selects the value to be formatted from the mapping

文件中的一个例子:>>> print '%(language)s has %(number)03d quote types.' % \

... {"language": "Python", "number": 2}

Python has 002 quote types.

因此,在%之后和{}之前()内的文本在字典中是key。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值