python中的字符串和文本
这是学习python的第6课,主要是讲 .format()的用法,.format()就是把前后两个字符串连接起来的。
types_of_people = 10
x = f"There are {types_of_people} 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_evalution = "Isn't that joke so funny?! {}"
print(joke_evalution.format(hilarious))
w = "This is the left side of..."
e = "a string with a right side."
print(w + e)
运行结果: