使用 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 Feb 28, 2016
google
|
3
tcitry Feb 28, 2016
|
4
shyling Feb 28, 2016
写 c 时熟悉了%d
|
5
pc10201 Feb 28, 2016
%格式化字符串是老式的写法
format 是新式的,而且功能更多 |
6
Kisesy Feb 28, 2016
你再学一段时间,就是这个了 log.debug(xxxx)
|
7
Ge4Los Feb 28, 2016
"this is tuple : %s" % (1,2,3) #不能直接使用元组。
"this is tuple:{}".format((1,2,3)) #可以直接使用元组。 而 %s 要想输出元组,就得用 ((1,2,3),) 作为参数了 |
8
erse Feb 28, 2016
最好用 format 而不是用%,有坑
|
9
feather12315 Feb 29, 2016 via Android
doc 建议 format
|