|
发表于 2017-5-26 13:56:12
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
想法是写一个判断奇偶的代码
然后写了这个
temp = input("输入一个数字判断单双:")
while not temp.isdigit():
temp = input("必须是数字\n再输入一次:")
number = temp
if number%2 ==0:
print ("是偶数噢")
else:
print ("是奇数噢")
然后运行的时候报错了…
这个是报错内容
输入一个数字判断单双:输入非数字还正常
必须是数字
再输入一次:6
Traceback (most recent call last):
File "<string>", line 2, in <module>
AttributeError: 'int' object has no attribute 'isdigit'
运行系统
Python 3.3.0 (default, Aug 13 2016, 17:03:14)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on unknown
Type "help", "copyright", "credits" or "license" for more information.
>>>
蠢新求助…
|
|