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