Python 输入()
函数允许用户在程序中输入。 输入()
函数从输入中读取一行,转换为细绳并将其作为方法返回值返回。
输入()
函数可选地允许将提示字符串作为在接受输入时显示给用户的方法参数。
输入()
方法从控制台获取用户名在给定的示例中,当在控制台中询问时,我输入了我的名字“Lokesh”。
x = input() print('Hello, ' + x)
程序输出。
Hello, Lokesh
输入()
Method输入()
方法的语法是:
input([prompt])
快速的 (选择修改的):一个字符串,表示标准输出(通常是屏幕)中输入前的消息。提示消息后没有尾随换行符。
输入()
方法读取用户在控制台输入的一行。它通过删除尾随的换行符将行转换为字符串并将其返回给程序。
如果我们尝试读取 EOF,它会抛出一个 EOFE 错误
异常。
输入()
Method ExampleuserInput = input() print('The input string is:', userInput)
程序输出。
cundage The input string is: cundage
inputNumber = input("Enter the number to get the square: ") print('The square of {0} is: {1}'.format( inputNumber, int(inputNumber) * int(inputNumber)))
程序输出。
Enter the number to get the square: 5 The square of 5 is: 25
快乐学习!!
地址:https://www.cundage.com/article/python-input.html