python 2.7转换为3.4。 3.4中的错误,2.7时没有错误

时间:2015-11-16 12:17:15

标签: python-3.4

我在python 2.4中测试并使用了这段代码。然而,一旦我转移到python 3.4,就会出现错误 - “TypeError:+:'int'和'str'的不支持的操作数类型。如果你设法找到原因,我将不胜感激正在发生。我将发布我在下面使用的代码

url: '/{type:(?:home|viz|about)}',

1 个答案:

答案 0 :(得分:0)

您不能将字符串用作索引

cipher += alphabetL[(alphabetL.index(A)+key1)%Ll]

alphabetL.index(A)整数key1字符串
因此,您必须将key1转换为整数

key1 = int(input('Please insert the key you want used [Keep between 1 and 26]: '))