[python]format的使用
来源:互联网 发布:苗勒管永存综合征 知乎 编辑:程序博客网 时间:2024/05/18 19:21
举例1: 使用{i}指定取哪个参数
>>> name="lucy">>> age=18>>> print "This is {0}, aged {1}".format(name, age) This is lucy, aged 18
{0}表示取第0个参数,{1}取第1个参数,分别对应name,age变量的值,从下例感受一下:
>>> print "This is {1}, aged {1}".format(name, age) This is 18, aged 18>>> print "This is {0}, aged {0}".format(name, age)This is lucy, aged lucy
举例2: 使用{key}指定取哪个参数
>>> print "This is {name}, aged {age}".format(name='lily', age=10) 第一个key是name,后面对这个key赋值This is lily, aged 10
阅读全文
0 0
- [python]format的使用
- python format的使用
- Python中format的使用
- python中 format的使用
- python format使用
- python format 使用 技巧
- python中format使用
- Python format 使用实例
- python的format函数
- python的format函数
- python的format函数
- python的%sVS.format
- python的format函数
- python format的应用
- format函数的使用
- format函数的使用
- string.format的使用
- format的使用
- Python3.5——运算符
- 像企业账号一样分发安装应用
- python异步操作MySQL(aiomysql)
- Python3读写csv文件
- core java chapter one An introduction to java
- [python]format的使用
- 微信电脑端-退出的群、删除的人,仍然可以查找或看到问题的解决方法
- 常用框架总结
- java生成-excel-并导出文件
- javaScript在页面中加载的先后顺序
- 一般论文投稿技巧
- 实现线程同步的方式
- 剑指offer--用O(1)的时间复杂度删除链表的节点
- 打印100~900水仙花数