Python 3.5 类型错误:Can';t转换为';int';对象隐式地为pascode系统创建str
im正在为密码系统创建一个代码,tahe将字母转换为数字 我做错了什么Python 3.5 类型错误:Can';t转换为';int';对象隐式地为pascode系统创建str,python-3.5,Python 3.5,im正在为密码系统创建一个代码,tahe将字母转换为数字 我做错了什么 abc = "....abcdefg......hijklm........nop.qrst......uvwx.yzæøå" def encode(letter): tall = abc.find(letter) return tall pw1 = "bb" output = "" for num in range(28): output = "" for character i
abc = "....abcdefg......hijklm........nop.qrst......uvwx.yzæøå"
def encode(letter):
tall = abc.find(letter)
return tall
pw1 = "bb"
output = ""
for num in range(28):
output = ""
for character in pw1:
if character in abc:
output = output + encode(character)
else:
output = output + character
print(secret)
print(output)
错误代码fom PHOTON3.5.2为
Traceback (most recent call last):
File "C:/Users/Artde/Desktop/Python/passord system.py", line 17, in <module>
output = output + encode(character)
TypeError: Can't convert 'int' object to str implicitly
回溯(最近一次呼叫最后一次):
文件“C:/Users/Artde/Desktop/Python/passord system.py”,第17行,在
输出=输出+编码(字符)
TypeError:无法将“int”对象隐式转换为str
find
ret运行字符串中字符的索引,因此在您的情况下,函数encode
将返回整数,output
是字符串
output=output+encode(character)
将给出错误,因此将其替换为output=output+str(encode(character))
find
重新运行字符串中字符的索引,因此在您的情况下函数encode
将返回整数,output
是字符串
output=output+encode(character)
将给出错误,因此将其替换为output=output+str(encode(character))
。但是我怎么能做到呢?因为它是10个而不是55个(我的意思是把数字加在一起)坦克。但是我怎么才能做到呢?因为是10而不是55(我的意思是把数字加起来)