【接口自动化测试】Python基础-字符串格式化
"""
字符串格式化
"""
name = 'Jenny'
age = 30
x = "my name is %s, age is 20" % name
print(x)
x1 = "my name is %s, age is %s" % (name, age)
print(x1)
# 第二种
y = "my name is {}, age is {}".format(name, age)
print(y)
# 第三种 f-string # python3.6以后新语法
z = f"my name is {name}, age is {age}"
print(z)
输出:
推荐最后一种方法