新手python编程问题
zs=input()forainrange(0,zs):c=a-1forbinrange(2,c):ifa%b==0:breakelse:print(a)结果为啥错误了1...
zs = input()
for a in range(0,zs):
c = a-1
for b in range(2,c):
if a%b == 0:
break
else:
print(a)
结果为啥错误了
10
Traceback (most recent call last):
File "C:/Users/鹿儿/Desktop/质数.py", line 2, in <module>
for a in range(0,zs):
TypeError: 'str' object cannot be interpreted as an integer
Process finished with exit code 1 展开
for a in range(0,zs):
c = a-1
for b in range(2,c):
if a%b == 0:
break
else:
print(a)
结果为啥错误了
10
Traceback (most recent call last):
File "C:/Users/鹿儿/Desktop/质数.py", line 2, in <module>
for a in range(0,zs):
TypeError: 'str' object cannot be interpreted as an integer
Process finished with exit code 1 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询