《Learn python3 the hard way》ex12 Prompting People

Prompting People


今天在敲这个代码的时候,我还在想我昨天是不是做了今天的份了,怎么那么像的,回头一看还是有 区别的,
昨天是先提前将提示语打印出,末位需要用end=""连接才能不换行,再用input给变量赋值。
今天是直接在input里面输入提示语并且赋值给变量
两者相比较就是语句变更简短了但还是显而易见。

age = input("How old are you?")
height = input("How tall are you?")
weight = input("how much do you weigh?")

print(f"So you're {are} old,{height} tall and {weight} heavy")

猜你喜欢

转载自blog.csdn.net/qq_43181584/article/details/83371445
今日推荐