Python 格式字符列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4480278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List of Python format characters
提问by orange
I've been looking for the list Python format characters for a good 30 minutes. I can't find any.
我一直在寻找 Python 格式字符列表长达 30 分钟。我找不到任何。
Examples are
例子是
%d, %r
%d, %r
etc but I need a list with them along with a description if possible please.
等等,但如果可能的话,我需要一份清单以及一份说明。
采纳答案by Lennart Regebro
Here you go, Python documentation on old string formatting. tutorial -> 7.1.1. Old String Formatting -> "More information can be found in the [link] section".
给你,关于旧字符串格式的Python 文档。教程 -> 7.1.1。旧字符串格式 ->“更多信息可以在 [link] 部分找到”。
Note that you should start using the new string formattingwhen possible.
请注意,您应该尽可能开始使用新的字符串格式。
回答by Lennart Regebro
It's the first result on Google: http://docs.python.org/library/stdtypes.html#string-formatting
这是谷歌的第一个结果:http: //docs.python.org/library/stdtypes.html#string-formatting
See also the new format() function: http://docs.python.org/library/stdtypes.html#str.format
另请参阅新的 format() 函数:http: //docs.python.org/library/stdtypes.html#str.format
回答by oceandreamer
In docs.python.org Topic = 5.6.2. String Formatting Operations http://docs.python.org/library/stdtypes.html#string-formattingthen further down to the chart (text above chart is "The conversion types are:")
在 docs.python.org 主题 = 5.6.2。字符串格式化操作 http://docs.python.org/library/stdtypes.html#string-formatting然后进一步向下到图表(图表上方的文字是“转换类型是:”)
The chart lists 16 types and some following notes.
该图表列出了 16 种类型和一些以下注意事项。
My comment: help does not include attitude which is a bonus. The attitude post enabled me to search further and find the info.
我的评论:帮助不包括作为奖励的态度。态度帖子使我能够进一步搜索并找到信息。

