这是学习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)

python中的字符串和文本

运行结果:
python中的字符串和文本

相关文章:

  • 2022-12-23
  • 2021-08-02
  • 2021-07-08
  • 2021-11-12
  • 2021-06-04
  • 2021-06-22
  • 2022-01-29
猜你喜欢
  • 2022-03-04
  • 2022-12-23
  • 2022-03-04
  • 2022-01-09
  • 2021-12-27
  • 2021-08-13
相关资源
相似解决方案