String formatting in Python

| \n | 换行   |
| \t | 制表符 |
| \  | 转义   |
| \\ | \      |

the '%' operator is used to format a set of variables enclosed in a "tuple" ( a fixed size list)
| %s                    | string                                                                       |
| %d                    | integers                                                                     |
| %f                    | floating point numbers                                                       |
| %.<number of digits>f | floating point numbers with a fixed amount of digits to the right of the dot |
| %x or %X              | Integers in hex representation|      

猜你喜欢

转载自www.cnblogs.com/code-saturne/p/10397471.html
今日推荐