《笨方法学Python》加分题6
types_of_people = 10 x = f"There are {types_of_people} types of peoples." 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)) #.format 要在已经创建的字符串上应用格式化 hilarious = "False" joke_evaluation = f"Isn't that joke so funny?! {hilarious}" print(joke_evaluation) w = "This is the left side of..." e = "a string with a right side." print(w + e)
.format的效果相当于把joke_evaluation的格式化写在了print函数里。
posted on 2018-11-19 19:46 阿加西的python之旅 阅读(235) 评论(0) 编辑 收藏 举报