📅  最后修改于: 2020-09-20 04:11:34             🧑  作者: Mango
input()
方法的语法为:
input([prompt])
input()
方法采用一个可选参数:
input()
方法从输入(通常是从用户)中读取一行,通过删除尾随的换行符将其转换为字符串 ,然后将其返回。
如果读取EOF,则会引发EOFError
异常。
# get input from user
inputString = input()
print('The inputted string is:', inputString)
输出
Python is interesting.
The inputted string is: Python is interesting
# get input from user
inputString = input('Enter a string:')
print('The inputted string is:', inputString)
输出
Enter a string: Python is interesting.
The inputted string is: Python is interesting