|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#编写一个函数 碾转法 求最大公约数
def gys123(a,b):
while True:
if a%b==0:
gys=b
break
else:
ys=a%b
b=ys
a=b
return gys
temp=input('请输入两个数字用逗号隔开:')
l=temp.find(',') #找到逗号位置
temp1=temp[:l] #用逗号分开两个数
temp2=temp[l:]
a=max(temp1,temp2)
b=min(temp1,temp2)
print(gys123(a,b))
错误
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\python\16.1.1.1.py", line 26, in <module>
print(gys123(a,b))
File "C:\Users\Administrator\Desktop\python\16.1.1.1.py", line 5, in gys123
if a%b==0:
TypeError: not all arguments converted during string formatting
这是哪里错误
本帖最后由 JessiFly 于 2018-8-25 18:01 编辑
a和b是字符串,b里面还多了个问号
比如我输入4和8:
|
|