代码
# Ex6 字符串和文本
# 字符串可以使用"f-string" 也可以使用.format()语法的格式化方式
# f"some stuff here {avariable}"
# f"som other stuff {anothervar}"
types_of_people = 10
x = f"There are {types_of_people} types of people."
binary = "binary"
do_not = "don't"
y = f"Those who know {binary} and those who {do_not}."
print(x)
print(y)
print(f"I said: {x}")
print(f"I also said: '{y}'")
hilarious = "False"
joke_evaluation = "Isn't that joke so funny?! {}"
print(joke_evaluation.format(hilarious))
w = "There is the left side of..."
e = "a string with a right side."
print(w + e)
运行结果
备注
1.全文有5处 把一个字符串放进另一个字符串的地方