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|      

posted @ 2019-02-18 19:46  kaiming_ai  阅读(216)  评论(0编辑  收藏  举报