Data input for python introductory basic learning

Data entry writing

1. Use a variable to receive or store input statementsGet keyboard input data.
Example:

print("你叫什么?")
name = input()
print("Get!你是%s" % name)

operation result:
insert image description here

2. If you don’t want to use the print statement to output the prompt, you can directly write the prompt statement in input(), and it will also be printed directly after running.
Syntax: input("prompt statement")
Example:


name = input("你叫什么?")
print("Get!你是%s" % name)

operation result:
insert image description here

Points to note

It is worth noting that the input content using input() isstr type, in this case, if you want to convert the data type, you need to convert it yourself.
Example:

num = input("你的密码是什么?")
num = int(num)  # 类型转换,转为int类型
print("密码是:", type(num))  # 验证数据类型

operation result:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44996886/article/details/132263130