python学习笔记——输入

inpute

input将用户输入的理解为字符串 

message=input("Tell me something,and I will repeat it back to you: ")
#这里可以多打一个空格用于区分原始文本和输入文本
print(message)

prompt="if you tell us who you are,we can personalize the messages you see"
prompt+="\nWhat is your first name: "
#在存储在prompt中的字符串末尾附加一个字符串

name=input(prompt)
print("\nHello,"+name +"!")

int 

height=input("How old are you,in inches?")
height=int(height)
                        
if height>=36:
    print("\nYou're tall enough to ride!")

 

* 如果用input输入会报错,因为无法让一个string个类型和一个int类型比较

猜你喜欢

转载自blog.csdn.net/qq_38882117/article/details/81206117
今日推荐