我知道这样的帖子已经存在,但是我没有帮助。
我正在尝试制作一个加密模块,由于某种原因,Python决定开始向我抛出错误。我可以修复大多数问题,但我认为到目前为止我还不错。这是我的代码:
def encrypt(x):
try:
if x == str(x):
x = str(x).split(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'].join(None))
x['a'] = 'q'
x['b'] = 'w'
x['c'] = 'e'
x['d'] = 'r'
x['e'] = 't'
x['f'] = 'y'
x['g'] = 'u'
x['h'] = 'i'
x['i'] = 'o'
x['j'] = 'p'
x['k'] = 'a'
x['l'] = 's'
x['m'] = 'd'
x['n'] = 'f'
x['o'] = 'g'
x['p'] = 'h'
x['q'] = 'j'
x['r'] = 'k'
x['s'] = 'l'
x['t'] = 'z'
x['u'] = 'x'
x['v'] = 'c'
x['w'] = 'v'
x['x'] = 'b'
x['y'] = 'n'
x['z'] = 'm'
return x
except TypeError and Exception as e:
raise TypeError('Cannot convert type to string.\nTech Notes: Original crash was: ' + str(e))
except Exception as e:
raise BaseException('Unknown failure of crash. Technical details below.\n' + str(e))
下面的崩溃详细信息。
返回的内容。
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/C e n s o r /Pythonista3/Documents/StupidCrypto/test.py",line 2,in <module>
a = stupidCrypto.encrypt('Ah')
File "/private/var/mobile/Containers/Shared/AppGroup/C e n s o r /Pythonista3/Documents/StupidCrypto/stupidCrypto.py",line 33,in encrypt
raise TypeError('Cannot convert type to string.\nTech Notes: Original crash was: ' + str(e))
TypeError: Cannot convert type to string.
Tech Notes: Original crash was: 'list' object has no attribute 'join'