练习6--字符串和文本

1 字符串定义补充:指的是一些你想要让你的程序呈现给别人或者”输出“出来的文本信息

2 格式字符串:f-String

3 .format()语法:本程序貌似使用了一个对象传入?我也没有特别搞明白

4 代码:

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 = "This is the left side of..."
e = "a string with a right side."
print(w+e)

5 执行结果

PS C:\Users\guohongzhen> cd E:\3_work\4_python\2_code\02_LearnPythonTheHardWay
PS E:\3_work\4_python\2_code\02_LearnPythonTheHardWay> python ex6.py
There are 10 types of people.
Those who know binary and those who don't.
I said:There are 10 types of people.
I also said:'Those who know binary and those who don't.'
Isn't that joke so funny?!False
This is the left side of...a string with a right side.

 

posted @ 2020-06-16 16:45  洛兰123  阅读(135)  评论(0编辑  收藏  举报