首页 > 技术文章 > Python中最简单快捷的输出方式

ludundun 原文

格式化输出最简单的方式之哑巴填充公式

name=ludundun

age=25

print(f'hello {name},your age is {age}')

输出内容:

hello ludundun,your age is 25 

Sally=6.66666666

print(f'your Sally is {Sally:.3f}')

精确获取小数点后三位进行结果输出。

输出内容:

your Sally is 6.667

推荐阅读