目录
一、format() 函数
format() 函数:
可用于多个字符串与多个变量值拼接,增强格式化。
二、format() 函数用法
format() 函数用法格式为:print('{}'.format())
每一个{},都对应 format 函数括号中的该位置变量值,format() 中的变量值用英文逗号隔开。
# ***************************** format() 函数实战 ***************************** #
import math
num1 = 45
num2 = 3.5
total1 = num1 * num2
num3 = 10
num4 = 2
total2 = num3 / num4
total = total1 + total2
print('数字 1 乘以数字 2 的结果值为:{}\n数字 3 除以数字 2 的结果值为:{}\n以上 2 个结果和为:{}'.format(total1,total2,total))