def num_isdigit(string):
if string == '': #排除空字符串
return False
else:
for c in string:
if not "0" <= c <= "9":
return False
else:
return True
while True: #实现循环输入
a = input("请随机输入一个字符串:")
if a == "N" or a == "n": #实现输入N/n时退出程序
print("程序已退出")
break
if num_isdigit(a):
print("{}字符串中全是数字".format(a))
else:
print("{}字符串中不全是数字".format(a))