发布网友 发布时间:2022-04-23 14:51
共4个回答
热心网友 时间:2023-10-03 01:56
input直接执行任何可执行的语句,因此是不安全的,建议使用raw_input, 返回字符串
s=raw_input('numbers: ')
while not s.isdigit():
s=raw_input('not a number, please try again: ')
热心网友 时间:2023-10-03 01:56
误,输出错误信息,
import re
if not re.findall('[0-9]+',str(x)):
raise SystemError("只能输入数字")
热心网友 时间:2023-10-03 01:56
没有这功能
热心网友 时间:2023-10-03 01:57
input没有这个功能。追问那要用什么代码?
追答呵呵,下边都出来了。。。row_input不能*用户只输入数字(我不知道python中是否有其它函数可以做到),只能输入后判断,错误的话再输入。
或者,用C写个模块来做这种输入。