最近比较忙~在调试新写的代码,没时间写~所以更新的慢啦!
特别特别篇(格式化输出)
字符串格式化输出:
我喜欢这种格式,用括号括起来,有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. |