请问代码中的temp是什么数据类型呢?
temp=input('请输入一个数字:')while not temp.isdigit():
temp=input('抱歉,您的输入有误,请输入一个整数:')
number=int(temp)
if number % 2 == 0:
print(temp + '是偶数')
else:
print(temp + '是奇数')
请问以上代码中的temp是什么数据类型呢? print(temp + '是偶数') 能够打印出来,说明temp是str,对吗?怎么理解呢?
是字符串 input() 返回字符串对象。
可以用 type(input()) 进行确定。 jackz007 发表于 2020-12-21 16:27
input() 返回字符串对象。
可以用 type(input()) 进行确定。
明白了,谢谢
页:
[1]