taizilongxu / interview_python

关于Python的面试题

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于字符串格式化

OctavianLee opened this issue · comments

字符串格式化确实有两种形式,某些库推荐使用%,譬如logging库,当你用format形式的时候,pylint检查会给warning。不过个人还是蛮喜欢format的。

format更优雅 哈哈

@taizilongxu 是的。这个issue只是说那个题目,不全面。很多库里,是推荐使用%的。

恩, 看了下logging是01年的老库, format是2.6版本新特性(08年), 看来很有可能是为了兼容的问题

哎 其实自己写的时候还是用%比较多...

嗯,所以 对那边的文字需要更正一下 说明 不过项目很赞,star了

: )

3.6的f-string更优雅,可以加到考题中