我想从键盘读取一个数字并验证它我如何通过Python中的函数传输变量
这是我所拥有但它不起作用。
没有错误,但它不记得数我介绍
def IsInteger(a):
try:
a=int(a)
return True
except ValueError:
return False
def read():
a=input("Nr: ")
while (IsInteger(a)!=True):
a=input("Give a number: ")
a=0
read()
print(a)
''''''''''''''''''''''''''''''''''''''read'你似乎已经知道如何使用'return',为什么不在'read()'中使用它呢? –
从'read'返回数字并将'a'重新赋值给返回的值 –