- 4
- 0
- 约1.6千字
- 约 8页
- 2022-04-11 发布于江西
- 举报
format 用法format用法相对基本格式化输出采用’%’的方法,format()功能更强大该函数把字符串当成一个模板通过传入的参数进行格式化并且使用大括号{}作为特殊字符代替%format用法hello worldhello worldhello world helloworld world helloworld hello worldprint({} {}.format(hello,world)) # 不带字段print({0} {1}.format(hello,world)) # 带数字编号print({0} {1} {0}.format(hello,world)) # 打乱顺序print({1} {1} {0}.format(hello,world))print({a} {tom} {a}.format(tom=hello,a=world)) # 带关键字1、位置/名字匹配(1)不带编号,即“{}”(2)带数字编号,可调换顺序,即“{1}”、“{2}”(3)带关键字,即“{a}”、“{tom}”format用法2、对象属性匹配c = 3-5jprint((complex{0},real:{0.real},imag:{0.imag}).format(c))complex(3-5j),real:3.0,imag:-5.0class Point: def __init
您可能关注的文档
最近下载
- (招聘面试)软件工程师招聘需求.pdf VIP
- 少先队鼓号队总谱pdf打印版.pdf VIP
- 《智慧运输运营》全套教学课件.pptx
- 机载激光雷达森林蓄积量建模技术规程.pdf VIP
- 第七章废水生物化学处理基础PowerPoint演示文.pptx VIP
- C++语言程序设计教程(第4版)杨进才课后习题答案解析.pdf
- 机载激光雷达数据制作1-50001-10000数字高程模型技术规程湖北地方标.pdf VIP
- 关于瓴睿资本相关情况的汇报材料.pdf VIP
- 清华当代给水与废水处理原理课件第7章 废水生物化学处理基础.ppt VIP
- 第7课时 比例的基本性质 课件 2026秋新苏教版数学六年级上册.pptx
原创力文档

文档评论(0)