最近比较忙~在调试新写的代码,没时间写~所以更新的慢啦!
特别特别篇(格式化输出)
字符串格式化输出:
我喜欢这种格式,用括号括起来,有c语言的感觉,所以我规定以后我的输出都用这种格式来输出东东。
Print “%format” %(content1, content2, …)
Format可以用的格式输出
| Conversion | Meaning |
| 'd' | Signed integer decimal. |
| 'i' | Signed integer decimal. |
| 'o' | Signed octal value. |
| 'u' | Obsolete type – it is identical to 'd'. |
| 'x' | Signed hexadecimal (lowercase). |
| 'X' | Signed hexadecimal (uppercase). |
| 'e' | Floating point exponential format (lowercase). |
| 'E' | Floating point exponential format (uppercase). |
| 'f' | Floating point decimal format. |
| 'F' | Floating point decimal format. |
| 'g' | Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. |
| 'G' | Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. |
| 'c' | Single character (accepts integer or single character string). |
| 'r' | String (converts any Python object using repr()). |
| 's' | String (converts any Python object using str()). |
| '%' | No argument is converted, results in a '%' character in the result. |
本文详细介绍了使用Python进行格式化字符串输出的方法,包括各种转换标志的含义及其应用场景,如整数、浮点数和字符等数据类型的格式化输出。
320

被折叠的 条评论
为什么被折叠?



