
使用 format 与%格式化字符串有什么区别。为什么我在文档里多用 format 而别人的项目里看到的都是用%
<script src="https://gist.github.com/imAArtist/116c5ed823fafa593e28.js"></script>
1 eote OP <script src="https://gist.github.com/imAArtist/116c5ed823fafa593e28.js"></script> |
2 WangYanjie 2016 年 2 月 28 日 google |
3 tcitry 2016 年 2 月 28 日 |
4 shyling 2016 年 2 月 28 日 写 c 时熟悉了%d |
5 pc10201 2016 年 2 月 28 日 %格式化字符串是老式的写法 format 是新式的,而且功能更多 |
6 Kisesy 2016 年 2 月 28 日 你再学一段时间,就是这个了 log.debug(xxxx) |
7 Ge4Los 2016 年 2 月 28 日 "this is tuple : %s" % (1,2,3) #不能直接使用元组。 "this is tuple:{}".format((1,2,3)) #可以直接使用元组。 而 %s 要想输出元组,就得用 ((1,2,3),) 作为参数了 |
8 erse 2016 年 2 月 28 日 最好用 format 而不是用%,有坑 |
9 feather12315 2016 年 2 月 29 日 via Android doc 建议 format |