Python【1】:input()


foreword

inputIs an important function to get user input from the keyboard


1. Grammar

input()The function in Python3.x accepts a standard input data, processes all inputs as strings by default, and returns as stringtype.

input([prompt])

Parameter Description:

  • prompt : print a prompt message on the terminal

2. Usage

2.1. Getting user input

>>>a = input("input:")
input:123                  # 输入整数
>>> type(a)
<class 'str'>              # 字符串

2.2. Getting Multiple Inputs

a, b, c = (input("input: ").split())

At this time, through split()the method , divide the input string into the desired number of copies and assign them to the corresponding variables

Guess you like

Origin blog.csdn.net/HoraceYan/article/details/128553862